|
@@ 597-619 (lines=23) @@
|
| 594 |
|
assert response.status_code == 404 |
| 595 |
|
assert mock_switch.enable.call_count == 0 |
| 596 |
|
|
| 597 |
|
@patch('napps.kytos.topology.main.Main.notify_switch_links_status') |
| 598 |
|
@patch('napps.kytos.topology.main.Main.notify_topology_update') |
| 599 |
|
async def test_disable_switch(self, mock_notify_topo, mock_sw_l_status): |
| 600 |
|
"""Test disable_switch.""" |
| 601 |
|
dpid = "00:00:00:00:00:00:00:01" |
| 602 |
|
mock_switch = get_switch_mock(dpid) |
| 603 |
|
self.napp.controller.switches = {dpid: mock_switch} |
| 604 |
|
|
| 605 |
|
endpoint = f"{self.base_endpoint}/switches/{dpid}/disable" |
| 606 |
|
response = await self.api_client.post(endpoint) |
| 607 |
|
assert response.status_code == 201 |
| 608 |
|
assert mock_switch.disable.call_count == 1 |
| 609 |
|
self.napp.topo_controller.disable_switch.assert_called_once_with(dpid) |
| 610 |
|
mock_notify_topo.assert_called() |
| 611 |
|
mock_sw_l_status.assert_called() |
| 612 |
|
|
| 613 |
|
# fail case |
| 614 |
|
mock_switch.disable.call_count = 0 |
| 615 |
|
dpid = "00:00:00:00:00:00:00:02" |
| 616 |
|
endpoint = f"{self.base_endpoint}/switches/{dpid}/disable" |
| 617 |
|
response = await self.api_client.post(endpoint) |
| 618 |
|
assert response.status_code == 404 |
| 619 |
|
assert mock_switch.disable.call_count == 0 |
| 620 |
|
|
| 621 |
|
async def test_get_switch_metadata(self): |
| 622 |
|
"""Test get_switch_metadata.""" |
|
@@ 573-595 (lines=23) @@
|
| 570 |
|
with pytest.raises(RestoreError): |
| 571 |
|
self.napp._load_link(link_attrs_fail) |
| 572 |
|
|
| 573 |
|
@patch('napps.kytos.topology.main.Main.notify_switch_links_status') |
| 574 |
|
@patch('napps.kytos.topology.main.Main.notify_topology_update') |
| 575 |
|
async def test_enable_switch(self, mock_notify_topo, mock_sw_l_status): |
| 576 |
|
"""Test enable_switch.""" |
| 577 |
|
dpid = "00:00:00:00:00:00:00:01" |
| 578 |
|
mock_switch = get_switch_mock(dpid) |
| 579 |
|
self.napp.controller.switches = {dpid: mock_switch} |
| 580 |
|
|
| 581 |
|
endpoint = f"{self.base_endpoint}/switches/{dpid}/enable" |
| 582 |
|
response = await self.api_client.post(endpoint) |
| 583 |
|
assert response.status_code == 201 |
| 584 |
|
assert mock_switch.enable.call_count == 1 |
| 585 |
|
self.napp.topo_controller.enable_switch.assert_called_once_with(dpid) |
| 586 |
|
mock_notify_topo.assert_called() |
| 587 |
|
mock_sw_l_status.assert_called() |
| 588 |
|
|
| 589 |
|
# fail case |
| 590 |
|
mock_switch.enable.call_count = 0 |
| 591 |
|
dpid = "00:00:00:00:00:00:00:02" |
| 592 |
|
endpoint = f"{self.base_endpoint}/switches/{dpid}/enable" |
| 593 |
|
response = await self.api_client.post(endpoint) |
| 594 |
|
assert response.status_code == 404 |
| 595 |
|
assert mock_switch.enable.call_count == 0 |
| 596 |
|
|
| 597 |
|
@patch('napps.kytos.topology.main.Main.notify_switch_links_status') |
| 598 |
|
@patch('napps.kytos.topology.main.Main.notify_topology_update') |