From 103186f5e8383b3378f9393addf06e3549dcd498 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 20 Mar 2017 16:49:20 -0400 Subject: [PATCH] Small renames to make team syncing code more clear --- data/model/team.py | 4 ++-- data/users/teamsync.py | 8 ++++---- data/users/test/test_teamsync.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/model/team.py b/data/model/team.py index 2da96df55..923951299 100644 --- a/data/model/team.py +++ b/data/model/team.py @@ -385,9 +385,9 @@ def confirm_team_invite(code, user_obj): return (team, inviter) -def list_federated_team_members(team, login_service_name): +def get_federated_team_member_mapping(team, login_service_name): """ Returns a dict of all federated IDs for all team members in the team whose users are - bound to the login service withn the given name. The dictionary is from federated service + bound to the login service within the given name. The dictionary is from federated service identifier (username) to their Quay User table ID. """ login_service = LoginService.get(name=login_service_name) diff --git a/data/users/teamsync.py b/data/users/teamsync.py index 571f1cc3d..65fc31b35 100644 --- a/data/users/teamsync.py +++ b/data/users/teamsync.py @@ -45,8 +45,8 @@ def sync_team(authentication, stale_team_sync): extra={'team': stale_team_sync.team_id, 'sync_config': sync_config}) # Load all the existing members of the team in Quay that are bound to the auth service. - existing_users = model.team.list_federated_team_members(stale_team_sync.team, - authentication.federated_service) + existing_users = model.team.get_federated_team_member_mapping(stale_team_sync.team, + authentication.federated_service) logger.debug('Existing membership of %s for team `%s` under organization %s via %s (#%s)', len(existing_users), stale_team_sync.team.name, @@ -109,8 +109,8 @@ def sync_team(authentication, stale_team_sync): # Update the transaction and last_updated time of the team sync. Only if it matches # the current value will we then perform the deletion step. - result = model.team.update_sync_status(stale_team_sync) - if not result: + got_transaction_handle = model.team.update_sync_status(stale_team_sync) + if not got_transaction_handle: # Another worker updated this team. Nothing more to do. logger.debug('Another worker synced team `%s` under organization %s via %s (#%s)', stale_team_sync.team.name, diff --git a/data/users/test/test_teamsync.py b/data/users/test/test_teamsync.py index 34bb42fcd..22d999123 100644 --- a/data/users/test/test_teamsync.py +++ b/data/users/test/test_teamsync.py @@ -183,7 +183,7 @@ def test_syncing(starting_membership, group_membership, expected_membership, app assert len(users_expected) + len(robots_expected) == len(expected_membership) # Check that the team's users match those expected. - service_user_map = model.team.list_federated_team_members(sync_team_info.team, _FAKE_AUTH) + service_user_map = model.team.get_federated_team_member_mapping(sync_team_info.team, _FAKE_AUTH) assert set(service_user_map.keys()) == users_expected quay_users = model.team.list_team_users(sync_team_info.team)