diff --git a/main.py b/main.py index ba4dffe..3fa0fa7 100644 --- a/main.py +++ b/main.py @@ -115,11 +115,12 @@ def get_kytos_topology(): return topology @listen_to("kytos/topology.topology_loaded") - def on_topology_loaded(self, event: KytosEvent): + def on_topology_loaded(self, _event: KytosEvent): """Handler for on topology_loaded.""" self.handler_on_topology_loaded() def handler_on_topology_loaded(self): + """Hnalder on_topology_loaded.""" self.load_kytos_topology() @listen_to("kytos/topology.updated") diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 844a8d5..1b928a0 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -115,6 +115,15 @@ async def test_create_l2vpn(self, requests_mock): assert response.status_code == 201 assert response.json() == {"service_id": "a123"} + def test_handler_on_topology_loaded(self): + """Test handler_on_topology_loaded.""" + self.napp.get_kytos_topology = MagicMock() + some_topo = {"switches": {"dpid1": {}}, "links": {"link1": {}}} + self.napp.get_kytos_topology.return_value = some_topo + self.napp.convert_topology_v2 = MagicMock() + self.napp.handler_on_topology_loaded() + assert self.napp._topo_dict == some_topo + @patch("requests.post") @patch("requests.patch") async def test_update_l2vpn(self, req_patch_mock, req_post_mock):