Skip to content

Commit

Permalink
hotfix: updated unit test accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
viniarck committed Sep 10, 2024
1 parent 932c49b commit c3f8159
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,12 +1245,10 @@ def test_interface_deleted(self, mock_handle_interface_link_down):
mock_handle_interface_link_down.assert_called()

@patch('napps.kytos.topology.main.Main._get_link_from_interface')
@patch('napps.kytos.topology.main.Main.notify_link_up_if_status')
@patch('napps.kytos.topology.main.Main.notify_topology_update')
def test_interface_link_up(self, *args):
"""Test interface link_up."""
(mock_notify_topology_update,
mock_notify_link_up_if_status,
mock_link_from_interface) = args

tnow = time.time()
Expand All @@ -1270,7 +1268,9 @@ def test_interface_link_up(self, *args):
mock_notify_topology_update.assert_called()
mock_link.extend_metadata.assert_called()
mock_link.activate.assert_called()
mock_notify_link_up_if_status.assert_called()
assert self.napp.controller.buffers.app.put.call_count == 2
ev = "kytos/topology.notify_link_up_if_status"
assert self.napp.controller.buffers.app.put.call_args[0][0].name == ev

@patch('napps.kytos.topology.main.Main._get_link_from_interface')
@patch('napps.kytos.topology.main.Main.notify_topology_update')
Expand Down Expand Up @@ -1375,12 +1375,10 @@ def test_handle_link_down_not_active_last_status(self, *args):
mock_status_change.assert_called()

@patch('napps.kytos.topology.main.Main._get_link_from_interface')
@patch('napps.kytos.topology.main.Main.notify_link_up_if_status')
@patch('napps.kytos.topology.main.Main.notify_topology_update')
def test_handle_link_up(self, *args):
"""Test handle link up."""
(mock_notify_topology_update,
mock_notify_link_up_if_status,
mock_link_from_interface) = args

mock_interface = create_autospec(Interface)
Expand All @@ -1389,8 +1387,10 @@ def test_handle_link_up(self, *args):
mock_link_from_interface.return_value = mock_link
self.napp.handle_link_up(mock_interface)
mock_interface.activate.assert_not_called()
assert mock_notify_link_up_if_status.call_count == 1
mock_notify_topology_update.assert_called()
assert self.napp.controller.buffers.app.put.call_count == 2
ev = "kytos/topology.notify_link_up_if_status"
assert self.napp.controller.buffers.app.put.call_args[0][0].name == ev

@patch('time.sleep')
@patch('napps.kytos.topology.main.Main._get_link_from_interface')
Expand Down

0 comments on commit c3f8159

Please sign in to comment.