diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 7b0ab3614ca..727b4393ba5 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -223,7 +223,7 @@ class Colored(Box): 'yum': "yum", 'ostree': "ostree", 'docker': "docker", - "ansible_collection": "ansible collection", + 'ansible_collection': "ansible_collection", 'file': "file", } diff --git a/robottelo/host_helpers/repository_mixins.py b/robottelo/host_helpers/repository_mixins.py index d721e90a3e9..f6ff272a724 100644 --- a/robottelo/host_helpers/repository_mixins.py +++ b/robottelo/host_helpers/repository_mixins.py @@ -204,6 +204,34 @@ def create(self, organization_id, product_id, download_policy=None, synchronize= return repo_info +class AnsibleRepository(BaseRepository): + """Custom Ansible Collection repository""" + + _type = constants.REPO_TYPE['ansible_collection'] + + def __init__(self, url=None, distro=None, requirements=None): + self._requirements = requirements + super().__init__(url=url, distro=distro) + + @property + def requirements(self): + return self._requirements + + def create(self, organization_id, product_id, download_policy=None, synchronize=True): + repo_info = self.satellite.cli_factory.make_repository( + { + 'product-id': product_id, + 'content-type': self.content_type, + 'url': self.url, + 'ansible-collection-requirements': f'{{collections: {self.requirements}}}', + } + ) + self._repo_info = repo_info + if synchronize: + self.synchronize() + return repo_info + + class OSTreeRepository(BaseRepository): """Custom OSTree repository""" diff --git a/tests/foreman/ui/test_repository.py b/tests/foreman/ui/test_repository.py index 1efba455ea0..5fbfe8ef947 100644 --- a/tests/foreman/ui/test_repository.py +++ b/tests/foreman/ui/test_repository.py @@ -673,7 +673,7 @@ def test_positive_sync_ansible_collection_gallaxy_repo(session, module_prod): module_prod.name, { 'name': repo_name, - 'repo_type': REPO_TYPE['ansible_collection'], + 'repo_type': REPO_TYPE['ansible_collection'].replace('_', ' '), 'repo_content.requirements': requirements, 'repo_content.upstream_url': ANSIBLE_GALAXY, },