From 0ca683aa38e745222254e8a1a5d8cb0154b11fe9 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Wed, 13 Mar 2024 17:08:36 -0500 Subject: [PATCH 1/4] Customer Case Automation - repo ids not being displayed --- robottelo/cli/contentview.py | 6 ++++ tests/foreman/cli/test_contentview.py | 41 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/robottelo/cli/contentview.py b/robottelo/cli/contentview.py index fb8001f89d7..157464ba804 100644 --- a/robottelo/cli/contentview.py +++ b/robottelo/cli/contentview.py @@ -208,3 +208,9 @@ def component_list(cls, options=None): """List components attached to the content view""" cls.command_sub = 'component list' return cls.execute(cls._construct_command(options), output_format='csv') + + @classmethod + def list(cls, options=None): + """List components attached to the content view""" + cls.command_sub = 'list' + return cls.execute(cls._construct_command(options), output_format='csv') diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 9b261f57218..137730fd95e 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -4065,6 +4065,47 @@ def test_version_info_by_lce(self, module_org, module_target_sat): ) assert content_view['version'] == '1.0' + @pytest.mark.tier2 + def test_show_all_repo_ids(self, module_org, module_product, module_target_sat): + """Hammer content-view list shows all repo ids + + :id: 56d716f1-85cf-47d7-a8e6-29788374d318 + + :steps: + 1. Add a large number of repositories to a CV + 2. Publish the CV + 3. Run hammer content-view list + + :expectedresults: All IDs for the repo are listed, and not truncated + + :BZ: 2141421 + + :customerscenario: true + """ + # Create 30 repositories + repolist = [] + id_list = [] + for _i in range(30): + repo = module_target_sat.api.Repository( + product=module_product, + checksum_type='sha256', + mirroring_policy='additive', + download_policy='immediate', + ).create() + repolist.append(repo) + id_list.append(str(repo.id)) + id_list = ', '.join(id_list) + # Sync and publish all repos + cv = module_target_sat.api.ContentView( + organization=module_org, repository=repolist + ).create() + for repo in repolist: + repo.sync() + cv.publish() + # Run content-view list --name cv.name + list_info = module_target_sat.cli.ContentView.list({'name': cv.name}) + assert (list_info[0]['repository-ids']) == id_list + class TestContentViewFileRepo: """Specific tests for Content Views with File Repositories containing From f127539743b6174039e087fb9a21df09dffb02fe Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Thu, 14 Mar 2024 16:40:00 -0500 Subject: [PATCH 2/4] fix cli method description, condense logic --- robottelo/cli/contentview.py | 2 +- tests/foreman/cli/test_contentview.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/robottelo/cli/contentview.py b/robottelo/cli/contentview.py index 157464ba804..5bd4810e853 100644 --- a/robottelo/cli/contentview.py +++ b/robottelo/cli/contentview.py @@ -211,6 +211,6 @@ def component_list(cls, options=None): @classmethod def list(cls, options=None): - """List components attached to the content view""" + """List information about content views""" cls.command_sub = 'list' return cls.execute(cls._construct_command(options), output_format='csv') diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 137730fd95e..56920e0d839 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -4085,7 +4085,7 @@ def test_show_all_repo_ids(self, module_org, module_product, module_target_sat): # Create 30 repositories repolist = [] id_list = [] - for _i in range(30): + for _ in range(30): repo = module_target_sat.api.Repository( product=module_product, checksum_type='sha256', @@ -4094,7 +4094,6 @@ def test_show_all_repo_ids(self, module_org, module_product, module_target_sat): ).create() repolist.append(repo) id_list.append(str(repo.id)) - id_list = ', '.join(id_list) # Sync and publish all repos cv = module_target_sat.api.ContentView( organization=module_org, repository=repolist @@ -4104,7 +4103,7 @@ def test_show_all_repo_ids(self, module_org, module_product, module_target_sat): cv.publish() # Run content-view list --name cv.name list_info = module_target_sat.cli.ContentView.list({'name': cv.name}) - assert (list_info[0]['repository-ids']) == id_list + assert (list_info[0]['repository-ids']) == ', '.join(id_list) class TestContentViewFileRepo: From 2b31c75dbf75d6e23be23a5e8a11fd5f9f519e64 Mon Sep 17 00:00:00 2001 From: Samuel Bible Date: Wed, 15 May 2024 16:41:51 -0500 Subject: [PATCH 3/4] Use set to be consistent in order Co-authored-by: vsedmik <46570670+vsedmik@users.noreply.github.com> --- tests/foreman/cli/test_contentview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 2aefd2b8997..8fb391c3bac 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -3342,7 +3342,7 @@ def test_show_all_repo_ids(self, module_org, module_product, module_target_sat): cv.publish() # Run content-view list --name cv.name list_info = module_target_sat.cli.ContentView.list({'name': cv.name}) - assert (list_info[0]['repository-ids']) == ', '.join(id_list) + assert set(list_info[0]['repository-ids']) == set(id_list) def test_positive_validate_force_promote_warning(self, target_sat, function_org): """Test cv promote shows warning of 'force promotion' for out of sequence LCE From a58780332cf11bcb1d7298aa53d7686dc7aa4461 Mon Sep 17 00:00:00 2001 From: vsedmik <46570670+vsedmik@users.noreply.github.com> Date: Thu, 16 May 2024 09:16:19 +0200 Subject: [PATCH 4/4] Update tests/foreman/cli/test_contentview.py --- tests/foreman/cli/test_contentview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 8fb391c3bac..548263ba6a3 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -3342,7 +3342,7 @@ def test_show_all_repo_ids(self, module_org, module_product, module_target_sat): cv.publish() # Run content-view list --name cv.name list_info = module_target_sat.cli.ContentView.list({'name': cv.name}) - assert set(list_info[0]['repository-ids']) == set(id_list) + assert set(list_info[0]['repository-ids'].split(', ')) == set(id_list) def test_positive_validate_force_promote_warning(self, target_sat, function_org): """Test cv promote shows warning of 'force promotion' for out of sequence LCE