|
@@ 374-386 (lines=13) @@
|
| 371 |
|
expected_result = circuits['1'] |
| 372 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 373 |
|
|
| 374 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 375 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |
| 376 |
|
"""Test if get_circuit return invalid circuit_id.""" |
| 377 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 378 |
|
'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/3' |
| 383 |
|
response = api.get(url) |
| 384 |
|
expected_result = 'circuit_id 3 not found' |
| 385 |
|
self.assertEqual(json.loads(response.data)['description'], |
| 386 |
|
expected_result) |
| 387 |
|
|
| 388 |
|
@patch('napps.kytos.mef_eline.models.evc.EVC.deploy') |
| 389 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
|
@@ 347-359 (lines=13) @@
|
| 344 |
|
expected_result = {'1': circuits['1']} |
| 345 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 346 |
|
|
| 347 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 348 |
|
def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock): |
| 349 |
|
"""Test if list circuits return all circuits.""" |
| 350 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 351 |
|
'2': {'name': 'circuit_2', 'archived': True}} |
| 352 |
|
storehouse_data_mock.return_value = circuits |
| 353 |
|
|
| 354 |
|
api = self.get_app_test_client(self.napp) |
| 355 |
|
url = f'{self.server_name_url}/v2/evc/?archived=True' |
| 356 |
|
|
| 357 |
|
response = api.get(url) |
| 358 |
|
expected_result = circuits |
| 359 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 360 |
|
|
| 361 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 362 |
|
def test_circuit_with_valid_id(self, storehouse_data_mock): |
|
@@ 333-345 (lines=13) @@
|
| 330 |
|
expected_result = circuits |
| 331 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 332 |
|
|
| 333 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 334 |
|
def test_list_with_archived_circuits_stored_1(self, storehouse_data_mock): |
| 335 |
|
"""Test if list circuits return only circuits not archived.""" |
| 336 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 337 |
|
'2': {'name': 'circuit_2', 'archived': True}} |
| 338 |
|
storehouse_data_mock.return_value = circuits |
| 339 |
|
|
| 340 |
|
api = self.get_app_test_client(self.napp) |
| 341 |
|
url = f'{self.server_name_url}/v2/evc/' |
| 342 |
|
|
| 343 |
|
response = api.get(url) |
| 344 |
|
expected_result = {'1': circuits['1']} |
| 345 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 346 |
|
|
| 347 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 348 |
|
def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock): |
|
@@ 361-372 (lines=12) @@
|
| 358 |
|
expected_result = circuits |
| 359 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 360 |
|
|
| 361 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 362 |
|
def test_circuit_with_valid_id(self, storehouse_data_mock): |
| 363 |
|
"""Test if get_circuit return the circuit attributes.""" |
| 364 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 365 |
|
'2': {'name': 'circuit_2'}} |
| 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/1' |
| 370 |
|
response = api.get(url) |
| 371 |
|
expected_result = circuits['1'] |
| 372 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 373 |
|
|
| 374 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 375 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |