Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions tests/foreman/cli/test_computeresource_osp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@
class TestOSPComputeResourceTestCase:
"""OSPComputeResource CLI tests."""

def cr_cleanup(self, cr_id, id_type, target_sat):
def cr_cleanup(self, id_type, value, target_sat):
"""Finalizer for removing CR from Satellite.
This should remove ssh key pairs from OSP in case of test fail.
"""
try:
target_sat.cli.ComputeResource.delete({id_type: cr_id})
assert not target_sat.cli.ComputeResource.exists(search=(id_type, cr_id))
except CLIReturnCodeError:
pass
target_sat.cli.ComputeResource.delete({id_type: value})
assert not target_sat.cli.ComputeResource.exists(search=(id_type, value))

@pytest.fixture
def osp_version(request):
Expand Down Expand Up @@ -76,7 +73,9 @@ def test_crud_and_duplicate_name(self, request, id_type, osp_version, target_sat
'url': osp_version,
}
)
request.addfinalizer(lambda: self.cr_cleanup(compute_resource['id'], id_type, target_sat))
request.addfinalizer(
lambda: self.cr_cleanup(id_type, compute_resource[id_type], target_sat)
)
assert compute_resource['name'] == name
assert target_sat.cli.ComputeResource.exists(search=(id_type, compute_resource[id_type]))

Expand Down
Loading