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

Fix a bug where ISIS metric restoration was not reflected in the subscription model of an IP trunk

Update and expand unit tests accordingly
parent 2ce66bb7
No related branches found
No related tags found
1 merge request!304Fix a bug where ISIS metric restoration was not reflected in the subscription model of an IP trunk
Pipeline #90224 failed
......@@ -631,6 +631,7 @@ def restore_isis_metric(
}
return {
"subscription": subscription,
"playbook_name": "gap_ansible/playbooks/iptrunks.yaml",
"inventory": {
"all": {
......
......@@ -109,6 +109,7 @@ def interface_lists_are_equal(list1, list2):
[UseJuniperSide.NONE, UseJuniperSide.SIDE_A, UseJuniperSide.SIDE_B, UseJuniperSide.SIDE_BOTH],
indirect=True,
)
@pytest.mark.parametrize("restore_isis_metric", [True, False])
@pytest.mark.workflow()
@patch("gso.services.infoblox.create_host_by_ip")
@patch("gso.services.infoblox.delete_host_by_ip")
......@@ -122,7 +123,7 @@ def interface_lists_are_equal(list1, list2):
@patch("gso.services.netbox_client.NetboxClient.free_interface")
@patch("gso.services.netbox_client.NetboxClient.delete_interface")
@patch("gso.workflows.iptrunk.migrate_iptrunk.SharePointClient")
def test_migrate_iptrunk_success(
def test_migrate_iptrunk_success( # noqa: PLR0915
mock_sharepoint_client,
mocked_delete_interface,
mocked_free_interface,
......@@ -136,6 +137,7 @@ def test_migrate_iptrunk_success(
mock_delete_host_by_ip,
mock_create_host_by_ip,
migrate_form_input,
restore_isis_metric,
data_config_filename: PathLike,
):
# Set up mock return values
......@@ -150,6 +152,7 @@ def test_migrate_iptrunk_success(
mocked_delete_interface.return_value = mocked_netbox.delete_interface()
mock_sharepoint_client.return_value = MockedSharePointClient
migrate_form_input[1]["restore_isis_metric"] = restore_isis_metric
result, process_stat, step_log = run_workflow("migrate_iptrunk", migrate_form_input)
for _ in range(8):
......@@ -161,10 +164,10 @@ def test_migrate_iptrunk_success(
for _ in range(8):
result, step_log = assert_lso_interaction_success(result, process_stat, step_log)
assert_suspended(result)
result, step_log = resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM)
if restore_isis_metric:
assert_suspended(result)
result, step_log = resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM)
for _ in range(1):
result, step_log = assert_lso_interaction_success(result, process_stat, step_log)
# Continue workflow after it has displayed a checklist URL.
......@@ -178,7 +181,7 @@ def test_migrate_iptrunk_success(
subscription = Iptrunk.from_subscription(subscription_id)
assert subscription.status == "active"
assert mock_execute_playbook.call_count == 17
assert mock_execute_playbook.call_count == 17 if restore_isis_metric else 16
assert mock_create_host_by_ip.call_count == 1
assert mock_delete_host_by_ip.call_count == 1
......@@ -216,3 +219,4 @@ def test_migrate_iptrunk_success(
assert subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_iface == new_lag_interface
existing_members = subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members
assert interface_lists_are_equal(new_lag_member_interfaces, existing_members)
assert (subscription.iptrunk.iptrunk_isis_metric == 999999) != restore_isis_metric
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment