diff --git a/pytest_fixtures/component/virtwho_config.py b/pytest_fixtures/component/virtwho_config.py index c5d4dc27500..a217d044d87 100644 --- a/pytest_fixtures/component/virtwho_config.py +++ b/pytest_fixtures/component/virtwho_config.py @@ -6,7 +6,6 @@ deploy_configure_by_command, deploy_configure_by_script, get_configure_command, - get_guest_info, ) LOGGEDOUT = 'Logged out.' @@ -337,11 +336,3 @@ def deploy_type_ui( script, form_data_ui['hypervisor_type'], debug=True, org=org_module.label ) return hypervisor_name, guest_name - - -@pytest.fixture -def delete_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() diff --git a/tests/foreman/virtwho/api/test_esx.py b/tests/foreman/virtwho/api/test_esx.py index e7544047d7e..73c92eda264 100644 --- a/tests/foreman/virtwho/api/test_esx.py +++ b/tests/foreman/virtwho/api/test_esx.py @@ -27,10 +27,19 @@ get_configure_command, get_configure_file, get_configure_option, + get_guest_info, ) -@pytest.mark.delete_host +@pytest.fixture(autouse=True) +def delete_host(form_data_api, target_sat): + guest_name, _ = get_guest_info(form_data_api['hypervisor_type']) + results = target_sat.api.Host().search(query={'search': guest_name}) + if results: + target_sat.api.Host(id=results[0].read_json()['id']).delete() + + +@pytest.mark.usefixtures('delete_host') class TestVirtWhoConfigforEsx: @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) diff --git a/tests/foreman/virtwho/api/test_kubevirt.py b/tests/foreman/virtwho/api/test_kubevirt.py index 88292e772db..21ee7e8cf4f 100644 --- a/tests/foreman/virtwho/api/test_kubevirt.py +++ b/tests/foreman/virtwho/api/test_kubevirt.py @@ -24,10 +24,19 @@ get_configure_command, get_configure_file, get_configure_option, + get_guest_info, ) -@pytest.mark.delete_host +@pytest.fixture(autouse=True) +def delete_host(form_data_api, target_sat): + guest_name, _ = get_guest_info(form_data_api['hypervisor_type']) + results = target_sat.api.Host().search(query={'search': guest_name}) + if results: + target_sat.api.Host(id=results[0].read_json()['id']).delete() + + +@pytest.mark.usefixtures('delete_host') class TestVirtWhoConfigforKubevirt: @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) diff --git a/tests/foreman/virtwho/api/test_nutanix.py b/tests/foreman/virtwho/api/test_nutanix.py index ae2726cf610..1a72138e1bf 100644 --- a/tests/foreman/virtwho/api/test_nutanix.py +++ b/tests/foreman/virtwho/api/test_nutanix.py @@ -26,11 +26,20 @@ get_configure_command, get_configure_file, get_configure_option, + get_guest_info, get_hypervisor_ahv_mapping, ) -@pytest.mark.delete_host +@pytest.fixture(autouse=True) +def delete_host(form_data_api, target_sat): + guest_name, _ = get_guest_info(form_data_api['hypervisor_type']) + results = target_sat.api.Host().search(query={'search': guest_name}) + if results: + target_sat.api.Host(id=results[0].read_json()['id']).delete() + + +@pytest.mark.usefixtures('delete_host') class TestVirtWhoConfigforNutanix: @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index 75652da9bd6..8f9db512bb6 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -35,13 +35,22 @@ get_configure_file, get_configure_id, get_configure_option, + get_guest_info, get_virtwho_status, restart_virtwho_service, update_configure_option, ) -@pytest.mark.delete_host +@pytest.fixture(autouse=True) +def delete_host(form_data_api, target_sat): + guest_name, _ = get_guest_info(form_data_api['hypervisor_type']) + results = target_sat.api.Host().search(query={'search': guest_name}) + if results: + target_sat.api.Host(id=results[0].read_json()['id']).delete() + + +@pytest.mark.usefixtures('delete_host') class TestVirtwhoConfigforEsx: @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) diff --git a/tests/foreman/virtwho/ui/test_esx_sca.py b/tests/foreman/virtwho/ui/test_esx_sca.py index 63c4c55a16b..92c208f19ca 100644 --- a/tests/foreman/virtwho/ui/test_esx_sca.py +++ b/tests/foreman/virtwho/ui/test_esx_sca.py @@ -32,13 +32,22 @@ get_configure_file, get_configure_id, get_configure_option, + get_guest_info, get_virtwho_status, restart_virtwho_service, update_configure_option, ) -@pytest.mark.delete_host +@pytest.fixture(autouse=True) +def delete_host(form_data_api, target_sat): + guest_name, _ = get_guest_info(form_data_api['hypervisor_type']) + results = target_sat.api.Host().search(query={'search': guest_name}) + if results: + target_sat.api.Host(id=results[0].read_json()['id']).delete() + + +@pytest.mark.usefixtures('delete_host') class TestVirtwhoConfigforEsx: @pytest.mark.tier2 @pytest.mark.upgrade