Small renames to make team syncing code more clear
This commit is contained in:
parent
7f0aa19292
commit
103186f5e8
3 changed files with 7 additions and 7 deletions
|
@ -385,9 +385,9 @@ def confirm_team_invite(code, user_obj):
|
||||||
return (team, inviter)
|
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
|
""" 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.
|
identifier (username) to their Quay User table ID.
|
||||||
"""
|
"""
|
||||||
login_service = LoginService.get(name=login_service_name)
|
login_service = LoginService.get(name=login_service_name)
|
||||||
|
|
|
@ -45,8 +45,8 @@ def sync_team(authentication, stale_team_sync):
|
||||||
extra={'team': stale_team_sync.team_id, 'sync_config': sync_config})
|
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.
|
# 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,
|
existing_users = model.team.get_federated_team_member_mapping(stale_team_sync.team,
|
||||||
authentication.federated_service)
|
authentication.federated_service)
|
||||||
|
|
||||||
logger.debug('Existing membership of %s for team `%s` under organization %s via %s (#%s)',
|
logger.debug('Existing membership of %s for team `%s` under organization %s via %s (#%s)',
|
||||||
len(existing_users), stale_team_sync.team.name,
|
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
|
# 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.
|
# the current value will we then perform the deletion step.
|
||||||
result = model.team.update_sync_status(stale_team_sync)
|
got_transaction_handle = model.team.update_sync_status(stale_team_sync)
|
||||||
if not result:
|
if not got_transaction_handle:
|
||||||
# Another worker updated this team. Nothing more to do.
|
# Another worker updated this team. Nothing more to do.
|
||||||
logger.debug('Another worker synced team `%s` under organization %s via %s (#%s)',
|
logger.debug('Another worker synced team `%s` under organization %s via %s (#%s)',
|
||||||
stale_team_sync.team.name,
|
stale_team_sync.team.name,
|
||||||
|
|
|
@ -183,7 +183,7 @@ def test_syncing(starting_membership, group_membership, expected_membership, app
|
||||||
assert len(users_expected) + len(robots_expected) == len(expected_membership)
|
assert len(users_expected) + len(robots_expected) == len(expected_membership)
|
||||||
|
|
||||||
# Check that the team's users match those expected.
|
# 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
|
assert set(service_user_map.keys()) == users_expected
|
||||||
|
|
||||||
quay_users = model.team.list_team_users(sync_team_info.team)
|
quay_users = model.team.list_team_users(sync_team_info.team)
|
||||||
|
|
Reference in a new issue