diff --git a/galaxy_ng/app/api/v1/serializers.py b/galaxy_ng/app/api/v1/serializers.py index 6b90e6ee33..ac6a6ac389 100644 --- a/galaxy_ng/app/api/v1/serializers.py +++ b/galaxy_ng/app/api/v1/serializers.py @@ -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() @@ -188,7 +199,7 @@ class Meta: 'created', 'modified', 'github_user', - # 'username', + 'username', 'github_repo', 'github_branch', 'commit', @@ -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): """ diff --git a/galaxy_ng/tests/integration/api/test_community.py b/galaxy_ng/tests/integration/api/test_community.py index c0f35c3aaa..60bead6b25 100644 --- a/galaxy_ng/tests/integration/api/test_community.py +++ b/galaxy_ng/tests/integration/api/test_community.py @@ -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 @@ -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])) @@ -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) diff --git a/galaxy_ng/tests/integration/utils/legacy.py b/galaxy_ng/tests/integration/utils/legacy.py index 6695310e9c..feb627ca2a 100644 --- a/galaxy_ng/tests/integration/utils/legacy.py +++ b/galaxy_ng/tests/integration/utils/legacy.py @@ -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)