Skip to content
Snippets Groups Projects
Commit 047f4f44 authored by Neda Moeini's avatar Neda Moeini
Browse files

Fixed test issue.

parent 9f4a6fba
Branches
Tags
1 merge request!94Feature/Netbox integration terminate ip trunk
......@@ -32,41 +32,32 @@ class MockedNetboxClient:
return self.BaseMockObject(id=1, name="test")
@pytest.fixture
def netbox_client_mock():
# Mock NetboxClient methods
with (
patch("gso.services.netbox_client.NetboxClient.get_device_by_name") as mock_get_device_by_name,
patch(
"gso.services.netbox_client.NetboxClient.get_interface_by_name_and_by_device_id"
) as mock_get_interface_by_name_and_by_device_id,
patch("gso.services.netbox_client.NetboxClient.delete_interface") as mock_delete_interface,
patch("gso.services.netbox_client.NetboxClient.free_interface") as mock_free_interface,
):
mock_get_device_by_name.return_value = MockedNetboxClient().get_device_by_name()
mock_get_interface_by_name_and_by_device_id.return_value = (
MockedNetboxClient().get_interface_by_name_and_by_device_id()
)
mock_delete_interface.return_value = MockedNetboxClient().delete_interface()
mock_free_interface.return_value = MockedNetboxClient().free_interface()
yield
@pytest.mark.workflow
@patch("gso.workflows.iptrunk.terminate_iptrunk.provisioning_proxy.provision_ip_trunk")
@patch("gso.workflows.iptrunk.terminate_iptrunk.provisioning_proxy.deprovision_ip_trunk")
@patch("gso.workflows.iptrunk.terminate_iptrunk.infoblox.delete_network")
@patch("gso.services.netbox_client.NetboxClient.get_device_by_name")
@patch("gso.services.netbox_client.NetboxClient.get_interface_by_name_and_by_device_id")
@patch("gso.services.netbox_client.NetboxClient.delete_interface")
@patch("gso.services.netbox_client.NetboxClient.free_interface")
def test_iptrunk_modify_isis_metric_success(
mocked_free_interface,
mocked_delete_interface,
mocked_get_interface_by_name_and_by_device_id,
mocked_get_device_by_name,
mock_infoblox_delete_network,
mock_deprovision_ip_trunk,
mock_provision_ip_trunk,
iptrunk_subscription_factory,
faker,
netbox_client_mock,
):
# Set up mock return values
product_id = iptrunk_subscription_factory()
mocked_netbox = MockedNetboxClient()
mocked_get_device_by_name.return_value = mocked_netbox.get_device_by_name()
mocked_get_interface_by_name_and_by_device_id.return_value = mocked_netbox.get_interface_by_name_and_by_device_id()
mocked_delete_interface.return_value = mocked_netbox.delete_interface()
mocked_free_interface.return_value = mocked_netbox.free_interface()
# Run workflow
initial_iptrunk_data = [
......@@ -95,6 +86,10 @@ def test_iptrunk_modify_isis_metric_success(
assert_complete(result)
# Check NetboxClient calls
assert mocked_delete_interface.call_count == 2 # once for each side
assert mocked_free_interface.call_count == 4 # Free interfaces for each side(2 per side)
state = extract_state(result)
subscription_id = state["subscription_id"]
subscription = Iptrunk.from_subscription(subscription_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment