From 0e587b6827ef98d64648705f919b1f8daf3becc5 Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Thu, 5 Sep 2024 14:26:37 +0530 Subject: [PATCH] add teardown condition to execute other test seamlessly --- tests/foreman/cli/test_subscription.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/foreman/cli/test_subscription.py b/tests/foreman/cli/test_subscription.py index 96e1458464a..cabd4fb575f 100644 --- a/tests/foreman/cli/test_subscription.py +++ b/tests/foreman/cli/test_subscription.py @@ -281,7 +281,7 @@ def test_positive_auto_attach_disabled_golden_ticket( assert "This host's organization is in Simple Content Access mode" in str(context.value) -def test_negative_check_katello_reimport(target_sat, function_org): +def test_negative_check_katello_reimport(request, target_sat, function_org): """Verify katello:reimport trace should not fail with an TypeError :id: b7508a1c-7798-4649-83a3-cf94c7409c96 @@ -297,6 +297,7 @@ def test_negative_check_katello_reimport(target_sat, function_org): :BZ: 2225534, 2253621 """ + request.addfinalizer(lambda: function_org.delete()) remote_path = f'/tmp/{EXPIRED_MANIFEST}' target_sat.put(DataFile.EXPIRED_MANIFEST_FILE, remote_path) # Import expired manifest & refresh @@ -307,13 +308,16 @@ def test_negative_check_katello_reimport(target_sat, function_org): 'grep -i "Katello::HttpErrors::BadRequest: This Organization\'s subscription ' 'manifest has expired. Please import a new manifest" /var/log/foreman/production.log' ) - assert exec_val.status + assert exec_val.status == 0 # Delete expired manifest target_sat.cli.Subscription.delete_manifest({'organization-id': function_org.id}) # Re-import new manifest & refresh manifester = Manifester(manifest_category=settings.manifest.golden_ticket) manifest = manifester.get_manifest() target_sat.upload_manifest(function_org.id, manifest.content) + request.addfinalizer( + lambda: target_sat.cli.Subscription.delete_manifest({'organization-id': function_org.id}) + ) ret_val = target_sat.cli.Subscription.refresh_manifest({'organization-id': function_org.id}) assert 'Candlepin job status: SUCCESS' in ret_val # Additional check, katello:reimport trace should not fail with TypeError