From eec1e79f37d4f6be89b90313af2a7c5a4a44d2c5 Mon Sep 17 00:00:00 2001 From: Cole Higgins Date: Fri, 8 Mar 2024 17:22:57 -0500 Subject: [PATCH 1/4] Test for creating a host with lce specified --- tests/foreman/cli/test_host.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index 42cd5a0719b..b40fa823f03 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2699,3 +2699,34 @@ def test_positive_create_and_update_with_content_source( target_sat.cli.Capsule.content_synchronize({'name': module_capsule_configured.hostname}) assert rhel_contenthost.execute(f'dnf -y install {package}').status == 0 assert rhel_contenthost.execute(f'rpm -q {package}').status == 0 + + +@pytest.mark.cli_host_create +@pytest.mark.tier2 +def test_positive_create_host_with_lifecycle_environment_name( + module_lce, module_org, module_promoted_cv, module_target_sat +): + """Attempt to create a host with lifecycle-environment name specified + + :id: 7445ad21-538f-4357-8bd1-9676d2478633 + + :BZ: 2106256 + + :expectedresults: Host is created with no errors + + :CaseImportance: Medium + """ + found_host = False + new_host = module_target_sat.cli_factory.make_fake_host( + { + 'content-view-id': module_promoted_cv.id, + 'lifecycle-environment': module_lce.name, + 'organization-id': module_org.id, + } + ) + hosts = module_target_sat.cli.Host.list({'organization-id': module_org.id}) + for i in hosts: + if new_host.name in i.values(): + found_host = True + break + assert found_host is True, 'Assertion failed: host not found' From da65548c0527180b8b1478241e8279bbab74e254 Mon Sep 17 00:00:00 2001 From: Cole Higgins Date: Mon, 1 Apr 2024 09:18:47 -0400 Subject: [PATCH 2/4] addressing comments --- tests/foreman/cli/test_host.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index b40fa823f03..ad8a1832e3c 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2725,8 +2725,5 @@ def test_positive_create_host_with_lifecycle_environment_name( } ) hosts = module_target_sat.cli.Host.list({'organization-id': module_org.id}) - for i in hosts: - if new_host.name in i.values(): - found_host = True - break - assert found_host is True, 'Assertion failed: host not found' + found_host = any(new_host.name in i.values() for i in hosts) + assert found_host, 'Assertion failed: host not found' From b8af331b0b957afe54edcb095b592f01ed059b4f Mon Sep 17 00:00:00 2001 From: Cole Higgins Date: Tue, 7 May 2024 10:40:22 -0400 Subject: [PATCH 3/4] rebase and adding to docstring --- tests/foreman/cli/test_host.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index ad8a1832e3c..de5f505de33 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2714,6 +2714,8 @@ def test_positive_create_host_with_lifecycle_environment_name( :expectedresults: Host is created with no errors + :customerscenario: true + :CaseImportance: Medium """ found_host = False From 458e78d14f2b2844a7cc615baf6e7e8ddd547c14 Mon Sep 17 00:00:00 2001 From: Cole Higgins Date: Wed, 8 May 2024 14:05:32 -0400 Subject: [PATCH 4/4] fixing docstring issue --- tests/foreman/cli/test_host.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index de5f505de33..d4d0742764b 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2704,7 +2704,10 @@ def test_positive_create_and_update_with_content_source( @pytest.mark.cli_host_create @pytest.mark.tier2 def test_positive_create_host_with_lifecycle_environment_name( - module_lce, module_org, module_promoted_cv, module_target_sat + module_lce, + module_org, + module_promoted_cv, + module_target_sat, ): """Attempt to create a host with lifecycle-environment name specified