From f9b74049e7d9f3f5bfddc60e7a763f0d7c11db4e Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 14 Feb 2024 04:30:33 -0500 Subject: [PATCH] [6.15.z] Test unassigning with multiple policies present (#14073) --- tests/foreman/ui/test_host.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index f5a5f9680af..afae39593d5 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -70,6 +70,9 @@ def scap_policy(scap_content, target_sat): return scap_policy +second_scap_policy = scap_policy + + @pytest.fixture(scope='module') def module_global_params(module_target_sat): """Create 3 global parameters and clean up at teardown""" @@ -317,7 +320,9 @@ def test_positive_assign_taxonomies( @pytest.mark.skip_if_not_set('oscap') @pytest.mark.tier2 -def test_positive_assign_compliance_policy(session, scap_policy, target_sat, function_host): +def test_positive_assign_compliance_policy( + session, scap_policy, second_scap_policy, target_sat, function_host +): """Ensure host compliance Policy can be assigned. :id: 323661a4-e849-4cc2-aa39-4b4a5fe2abed @@ -338,12 +343,13 @@ def test_positive_assign_compliance_policy(session, scap_policy, target_sat, fun organization=content.organization, location=content.location, ).update(['organization', 'location']) + for sp in [scap_policy, second_scap_policy]: + target_sat.api.CompliancePolicies( + id=sp['id'], + organization=content.organization, + location=content.location, + ).update(['organization', 'location']) - target_sat.api.CompliancePolicies( - id=scap_policy['id'], - organization=content.organization, - location=content.location, - ).update(['organization', 'location']) with session: session.organization.select(org_name=org.name) session.location.select(loc_name=loc.name) @@ -352,6 +358,9 @@ def test_positive_assign_compliance_policy(session, scap_policy, target_sat, fun session.host.apply_action( 'Assign Compliance Policy', [function_host.name], {'policy': scap_policy['name']} ) + session.host.apply_action( + 'Assign Compliance Policy', [function_host.name], {'policy': second_scap_policy['name']} + ) assert ( session.host.search(f'compliance_policy = {scap_policy["name"]}')[0]['Name'] == function_host.name @@ -367,6 +376,10 @@ def test_positive_assign_compliance_policy(session, scap_policy, target_sat, fun 'Unassign Compliance Policy', [function_host.name], {'policy': scap_policy['name']} ) assert not session.host.search(f'compliance_policy = {scap_policy["name"]}') + assert ( + session.host.search(f'compliance_policy = {second_scap_policy["name"]}')[0]['Name'] + == function_host.name + ) @pytest.mark.skipif((settings.ui.webdriver != 'chrome'), reason='Only tested on Chrome')