Skip to content

Commit

Permalink
use pytest.mark.usefixtures for delete_host
Browse files Browse the repository at this point in the history
  • Loading branch information
yanpliu committed Nov 29, 2023
1 parent 1ce96d4 commit 621bc0c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 14 deletions.
9 changes: 0 additions & 9 deletions pytest_fixtures/component/virtwho_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
deploy_configure_by_command,
deploy_configure_by_script,
get_configure_command,
get_guest_info,
)

LOGGEDOUT = 'Logged out.'
Expand Down Expand Up @@ -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()
11 changes: 10 additions & 1 deletion tests/foreman/virtwho/api/test_esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion tests/foreman/virtwho/api/test_kubevirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion tests/foreman/virtwho/api/test_nutanix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion tests/foreman/virtwho/ui/test_esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion tests/foreman/virtwho/ui/test_esx_sca.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 621bc0c

Please sign in to comment.