From 8bf71d078e2ed601c4e370997bd35e4353d606cd Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Tue, 9 Apr 2024 16:42:22 +0530 Subject: [PATCH] Fix teardown of bootdisk tests with request.addfinalizer Signed-off-by: Gaurav Talreja --- tests/foreman/cli/test_bootdisk.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/foreman/cli/test_bootdisk.py b/tests/foreman/cli/test_bootdisk.py index 4775c3bbdea..5e0ca29eec6 100644 --- a/tests/foreman/cli/test_bootdisk.py +++ b/tests/foreman/cli/test_bootdisk.py @@ -20,6 +20,7 @@ @pytest.mark.rhel_ver_match('[^6]') def test_positive_bootdisk_download_https( + request, module_location, module_sync_kickstart_content, module_provisioning_capsule, @@ -79,8 +80,12 @@ def test_positive_bootdisk_download_https( 'lifecycle-environment-id': module_lce_library.id, } ) + + @request.addfinalizer + def _finalize(): + module_target_sat.api.Host(id=host.id).delete() + module_target_sat.api.Media(id=media['id']).delete() + # Check if full-host bootdisk can be downloaded. bootdisk = module_target_sat.cli.Bootdisk.host({'host-id': host['id'], 'full': 'true'}) assert 'Successfully downloaded host disk image' in bootdisk['message'] - module_target_sat.api.Host(id=host.id).delete() - module_target_sat.api.Media(id=media['id']).delete()