|
@@ 349-369 (lines=21) @@
|
| 346 |
|
self.assertEqual(response.status_code, 404, response.data) |
| 347 |
|
self.assertEqual(mock_switch.enable.call_count, 0) |
| 348 |
|
|
| 349 |
|
@patch('napps.kytos.topology.main.Main.save_status_on_storehouse') |
| 350 |
|
def test_disable_switch(self, mock_save_status): |
| 351 |
|
"""Test disable_switch.""" |
| 352 |
|
dpid = "00:00:00:00:00:00:00:01" |
| 353 |
|
mock_switch = get_switch_mock(dpid) |
| 354 |
|
self.napp.controller.switches = {dpid: mock_switch} |
| 355 |
|
api = get_test_client(self.napp.controller, self.napp) |
| 356 |
|
|
| 357 |
|
url = f'{self.server_name_url}/v3/switches/{dpid}/disable' |
| 358 |
|
response = api.post(url) |
| 359 |
|
self.assertEqual(response.status_code, 201, response.data) |
| 360 |
|
self.assertEqual(mock_switch.disable.call_count, 1) |
| 361 |
|
mock_save_status.assert_called() |
| 362 |
|
|
| 363 |
|
# fail case |
| 364 |
|
mock_switch.disable.call_count = 0 |
| 365 |
|
dpid = "00:00:00:00:00:00:00:02" |
| 366 |
|
url = f'{self.server_name_url}/v3/switches/{dpid}/disable' |
| 367 |
|
response = api.post(url) |
| 368 |
|
self.assertEqual(response.status_code, 404, response.data) |
| 369 |
|
self.assertEqual(mock_switch.disable.call_count, 0) |
| 370 |
|
|
| 371 |
|
def test_get_switch_metadata(self): |
| 372 |
|
"""Test get_switch_metadata.""" |
|
@@ 327-347 (lines=21) @@
|
| 324 |
|
with self.assertRaises(KeyError): |
| 325 |
|
self.napp._restore_switch(dpid_fail) |
| 326 |
|
|
| 327 |
|
@patch('napps.kytos.topology.main.Main.save_status_on_storehouse') |
| 328 |
|
def test_enable_switch(self, mock_save_status): |
| 329 |
|
"""Test enable_switch.""" |
| 330 |
|
dpid = "00:00:00:00:00:00:00:01" |
| 331 |
|
mock_switch = get_switch_mock(dpid) |
| 332 |
|
self.napp.controller.switches = {dpid: mock_switch} |
| 333 |
|
api = get_test_client(self.napp.controller, self.napp) |
| 334 |
|
|
| 335 |
|
url = f'{self.server_name_url}/v3/switches/{dpid}/enable' |
| 336 |
|
response = api.post(url) |
| 337 |
|
self.assertEqual(response.status_code, 201, response.data) |
| 338 |
|
self.assertEqual(mock_switch.enable.call_count, 1) |
| 339 |
|
mock_save_status.assert_called() |
| 340 |
|
|
| 341 |
|
# fail case |
| 342 |
|
mock_switch.enable.call_count = 0 |
| 343 |
|
dpid = "00:00:00:00:00:00:00:02" |
| 344 |
|
url = f'{self.server_name_url}/v3/switches/{dpid}/enable' |
| 345 |
|
response = api.post(url) |
| 346 |
|
self.assertEqual(response.status_code, 404, response.data) |
| 347 |
|
self.assertEqual(mock_switch.enable.call_count, 0) |
| 348 |
|
|
| 349 |
|
@patch('napps.kytos.topology.main.Main.save_status_on_storehouse') |
| 350 |
|
def test_disable_switch(self, mock_save_status): |