|
@@ 356-368 (lines=13) @@
|
| 353 |
|
expected_result = circuits['1'] |
| 354 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 355 |
|
|
| 356 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 357 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |
| 358 |
|
"""Test if get_circuit return invalid circuit_id.""" |
| 359 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 360 |
|
'2': {'name': 'circuit_2'}} |
| 361 |
|
storehouse_data_mock.return_value = circuits |
| 362 |
|
|
| 363 |
|
api = self.get_app_test_client(self.napp) |
| 364 |
|
url = f'{self.server_name_url}/v2/evc/3' |
| 365 |
|
response = api.get(url) |
| 366 |
|
expected_result = 'circuit_id 3 not found' |
| 367 |
|
self.assertEqual(json.loads(response.data)['description'], |
| 368 |
|
expected_result) |
| 369 |
|
|
| 370 |
|
@patch('napps.kytos.mef_eline.models.evc.EVC.deploy') |
| 371 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
|
@@ 329-341 (lines=13) @@
|
| 326 |
|
expected_result = {'1': circuits['1']} |
| 327 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 328 |
|
|
| 329 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 330 |
|
def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock): |
| 331 |
|
"""Test if list circuits return all circuits.""" |
| 332 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 333 |
|
'2': {'name': 'circuit_2', 'archived': True}} |
| 334 |
|
storehouse_data_mock.return_value = circuits |
| 335 |
|
|
| 336 |
|
api = self.get_app_test_client(self.napp) |
| 337 |
|
url = f'{self.server_name_url}/v2/evc/?archived=True' |
| 338 |
|
|
| 339 |
|
response = api.get(url) |
| 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_circuit_with_valid_id(self, storehouse_data_mock): |
|
@@ 315-327 (lines=13) @@
|
| 312 |
|
expected_result = circuits |
| 313 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 314 |
|
|
| 315 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 316 |
|
def test_list_with_archived_circuits_stored_1(self, storehouse_data_mock): |
| 317 |
|
"""Test if list circuits return only circuits not archived.""" |
| 318 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 319 |
|
'2': {'name': 'circuit_2', 'archived': True}} |
| 320 |
|
storehouse_data_mock.return_value = circuits |
| 321 |
|
|
| 322 |
|
api = self.get_app_test_client(self.napp) |
| 323 |
|
url = f'{self.server_name_url}/v2/evc/' |
| 324 |
|
|
| 325 |
|
response = api.get(url) |
| 326 |
|
expected_result = {'1': circuits['1']} |
| 327 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 328 |
|
|
| 329 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 330 |
|
def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock): |
|
@@ 343-354 (lines=12) @@
|
| 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_circuit_with_valid_id(self, storehouse_data_mock): |
| 345 |
|
"""Test if get_circuit return the circuit attributes.""" |
| 346 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 347 |
|
'2': {'name': 'circuit_2'}} |
| 348 |
|
storehouse_data_mock.return_value = circuits |
| 349 |
|
|
| 350 |
|
api = self.get_app_test_client(self.napp) |
| 351 |
|
url = f'{self.server_name_url}/v2/evc/1' |
| 352 |
|
response = api.get(url) |
| 353 |
|
expected_result = circuits['1'] |
| 354 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 355 |
|
|
| 356 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 357 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |