Skip to content
Snippets Groups Projects
Verified Commit ac9b297a authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

parametrize unit test for router termination workflow

parent 390d642f
Branches
Tags
1 merge request!136Run playbook when terminating router
Pipeline #85303 passed
......@@ -3,10 +3,19 @@ from unittest.mock import patch
import pytest
from gso.products import Router
from test.workflows import assert_complete, extract_state, run_workflow, assert_pp_interaction_success
from test.workflows import assert_complete, assert_pp_interaction_success, extract_state, run_workflow
@pytest.mark.workflow()
@pytest.mark.parametrize(
("remove_configuration", "clean_up_ipam"),
[
(True, True),
(True, False),
(False, True),
(False, False),
],
)
@patch("gso.services.provisioning_proxy._send_request")
@patch("gso.workflows.router.terminate_router.NetboxClient.delete_device")
@patch("gso.workflows.router.terminate_router.infoblox.delete_host_by_ip")
......@@ -14,23 +23,26 @@ def test_terminate_router_full_success(
mock_delete_host_by_ip,
mock_delete_device,
mock_execute_playbook,
remove_configuration,
clean_up_ipam,
nokia_router_subscription_factory,
faker,
data_config_filename,
):
# Set up active subscription in database
# Prepare mock values and expected results
product_id = nokia_router_subscription_factory()
router_termination_input_form_data = {
"tt_number": faker.tt_number(),
"remove_configuration": True,
"clean_up_ipam": True,
"remove_configuration": remove_configuration,
"clean_up_ipam": clean_up_ipam,
}
pp_interaction_count = 2 if remove_configuration else 0
# Run workflow
initial_router_data = [{"subscription_id": product_id}, router_termination_input_form_data]
result, process_stat, step_log = run_workflow("terminate_router", initial_router_data)
for _ in range(2):
for _ in range(pp_interaction_count):
result, step_log = assert_pp_interaction_success(result, process_stat, step_log)
assert_complete(result)
......@@ -41,5 +53,5 @@ def test_terminate_router_full_success(
assert subscription.status == "terminated"
assert mock_delete_device.call_count == 1
assert mock_delete_host_by_ip.call_count == 1
assert mock_execute_playbook.call_count == 2
assert mock_delete_host_by_ip.call_count == (1 if clean_up_ipam else 0)
assert mock_execute_playbook.call_count == pp_interaction_count
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment