Skip to content

Commit

Permalink
Fix tests?
Browse files Browse the repository at this point in the history
No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner committed Oct 9, 2023
1 parent 6391c9e commit 2e0fe5e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
19 changes: 15 additions & 4 deletions galaxy_ng/app/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,23 @@ def get_avatar_url(self, obj):

class LegacyRoleSerializer(serializers.ModelSerializer):

# username = serializers.SerializerMethodField()
# core cli uses this field to emit the list of
# results from a role search so it must exit
username = serializers.SerializerMethodField()

# this has to be the real github org/user so that
# role installs will work
github_user = serializers.SerializerMethodField()

# this has to be the real github repository name
# so that role installs will work
github_repo = serializers.SerializerMethodField()

github_branch = serializers.SerializerMethodField()

commit = serializers.SerializerMethodField()
commit_message = serializers.SerializerMethodField()

description = serializers.SerializerMethodField()
summary_fields = serializers.SerializerMethodField()
upstream_id = serializers.SerializerMethodField()
Expand All @@ -188,7 +199,7 @@ class Meta:
'created',
'modified',
'github_user',
# 'username',
'username',
'github_repo',
'github_branch',
'commit',
Expand Down Expand Up @@ -235,8 +246,8 @@ def get_github_user(self, obj):
return obj.full_metadata['github_user']
return obj.namespace.name

# def get_username(self, obj):
# return obj.namespace.name
def get_username(self, obj):
return obj.namespace.name

def get_github_repo(self, obj):
"""
Expand Down
15 changes: 8 additions & 7 deletions galaxy_ng/tests/integration/api/test_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def test_v1_autocomplete_search(ansible_config):
# query by user
resp = api_client(f'/api/v1/roles/?owner__username={github_user}')
assert resp['count'] > 0
usernames = sorted(set([x['username'] for x in resp['results']]))
usernames = sorted(set([x['github_user'] for x in resp['results']]))
assert usernames == [github_user]

# validate autocomplete search only finds the relevant roles
Expand Down Expand Up @@ -566,11 +566,11 @@ def get_roles(page_size=1, order_by='created'):
urls, all_roles = get_roles(page_size=1, order_by='created')
roles = [[x['created'], x['id']] for x in all_roles]

# make sure all 10 show up ...
assert len(roles) == 10
total_count = len(urls)
assert total_count >= 10

# make sure all pages were visited
assert len(urls) == 10
# make sure all 10 show up ...
assert len(roles) == total_count

# make sure no duplicates found
assert [x[1] for x in roles] == sorted(set([x[1] for x in roles]))
Expand All @@ -581,9 +581,10 @@ def get_roles(page_size=1, order_by='created'):
# repeat with ordered by name ...
urls, all_roles = get_roles(page_size=1, order_by='name')
roles = [x['name'] for x in all_roles]

assert roles == sorted(roles)
assert len(roles) == 10
assert len(sorted(set(roles))) == 10
assert len(roles) == total_count
assert len(sorted(set(roles))) == total_count

# cleanup
clean_all_roles(ansible_config)
Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/tests/integration/utils/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def clean_all_roles(ansible_config):
break
next_url = resp['next']

usernames = [x['username'] for x in pre_existing]
usernames = [x['github_user'] for x in pre_existing]
usernames = sorted(set(usernames))
for username in usernames:
cleanup_social_user(username, ansible_config)
Expand Down

0 comments on commit 2e0fe5e

Please sign in to comment.