Skip to content

Commit

Permalink
tests: covered with unit tests accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
viniarck committed Nov 7, 2024
1 parent ff2e24a commit e8ad4cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e8ad4cb

Please sign in to comment.