|
@@ 359-371 (lines=13) @@
|
| 356 |
|
expected_result = {"1": circuits["1"]} |
| 357 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 358 |
|
|
| 359 |
|
@patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data") |
| 360 |
|
def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock): |
| 361 |
|
"""Test if list circuits return all circuits.""" |
| 362 |
|
circuits = { |
| 363 |
|
"1": {"name": "circuit_1"}, |
| 364 |
|
"2": {"name": "circuit_2", "archived": True}, |
| 365 |
|
} |
| 366 |
|
storehouse_data_mock.return_value = circuits |
| 367 |
|
|
| 368 |
|
api = self.get_app_test_client(self.napp) |
| 369 |
|
url = f"{self.server_name_url}/v2/evc/?archived=True" |
| 370 |
|
|
| 371 |
|
response = api.get(url) |
| 372 |
|
expected_result = circuits |
| 373 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 374 |
|
|
|
@@ 343-355 (lines=13) @@
|
| 340 |
|
expected_result = circuits |
| 341 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 342 |
|
|
| 343 |
|
@patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data") |
| 344 |
|
def test_list_with_archived_circuits_stored_1(self, storehouse_data_mock): |
| 345 |
|
"""Test if list circuits return only circuits not archived.""" |
| 346 |
|
circuits = { |
| 347 |
|
"1": {"name": "circuit_1"}, |
| 348 |
|
"2": {"name": "circuit_2", "archived": True}, |
| 349 |
|
} |
| 350 |
|
storehouse_data_mock.return_value = circuits |
| 351 |
|
|
| 352 |
|
api = self.get_app_test_client(self.napp) |
| 353 |
|
url = f"{self.server_name_url}/v2/evc/" |
| 354 |
|
|
| 355 |
|
response = api.get(url) |
| 356 |
|
expected_result = {"1": circuits["1"]} |
| 357 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 358 |
|
|
|
@@ 387-399 (lines=13) @@
|
| 384 |
|
expected_result = circuits["1"] |
| 385 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 386 |
|
|
| 387 |
|
@patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data") |
| 388 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |
| 389 |
|
"""Test if get_circuit return invalid circuit_id.""" |
| 390 |
|
circuits = {"1": {"name": "circuit_1"}, "2": {"name": "circuit_2"}} |
| 391 |
|
storehouse_data_mock.return_value = circuits |
| 392 |
|
|
| 393 |
|
api = self.get_app_test_client(self.napp) |
| 394 |
|
url = f"{self.server_name_url}/v2/evc/3" |
| 395 |
|
response = api.get(url) |
| 396 |
|
expected_result = "circuit_id 3 not found" |
| 397 |
|
self.assertEqual( |
| 398 |
|
json.loads(response.data)["description"], expected_result |
| 399 |
|
) |
| 400 |
|
|
| 401 |
|
@patch("napps.kytos.mef_eline.models.evc.EVC.deploy") |
| 402 |
|
@patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data") |
|
@@ 375-386 (lines=12) @@
|
| 372 |
|
expected_result = circuits |
| 373 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 374 |
|
|
| 375 |
|
@patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data") |
| 376 |
|
def test_circuit_with_valid_id(self, storehouse_data_mock): |
| 377 |
|
"""Test if get_circuit return the circuit attributes.""" |
| 378 |
|
circuits = {"1": {"name": "circuit_1"}, "2": {"name": "circuit_2"}} |
| 379 |
|
storehouse_data_mock.return_value = circuits |
| 380 |
|
|
| 381 |
|
api = self.get_app_test_client(self.napp) |
| 382 |
|
url = f"{self.server_name_url}/v2/evc/1" |
| 383 |
|
response = api.get(url) |
| 384 |
|
expected_result = circuits["1"] |
| 385 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 386 |
|
|
| 387 |
|
@patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data") |
| 388 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |
| 389 |
|
"""Test if get_circuit return invalid circuit_id.""" |