|
@@ 293-305 (lines=13) @@
|
| 290 |
|
expected_result = circuits['1'] |
| 291 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 292 |
|
|
| 293 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 294 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |
| 295 |
|
"""Test if get_circuit return invalid circuit_id.""" |
| 296 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 297 |
|
'2': {'name': 'circuit_2'}} |
| 298 |
|
storehouse_data_mock.return_value = circuits |
| 299 |
|
|
| 300 |
|
api = self.get_app_test_client(self.napp) |
| 301 |
|
url = f'{self.server_name_url}/v2/evc/3' |
| 302 |
|
response = api.get(url) |
| 303 |
|
expected_result = 'circuit_id 3 not found' |
| 304 |
|
self.assertEqual(json.loads(response.data)['description'], |
| 305 |
|
expected_result) |
| 306 |
|
|
| 307 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 308 |
|
@patch('napps.kytos.mef_eline.scheduler.Scheduler.add') |
|
@@ 266-278 (lines=13) @@
|
| 263 |
|
expected_result = {'1': circuits['1']} |
| 264 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 265 |
|
|
| 266 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 267 |
|
def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock): |
| 268 |
|
"""Test if list circuits return all circuits.""" |
| 269 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 270 |
|
'2': {'name': 'circuit_2', 'archived': True}} |
| 271 |
|
storehouse_data_mock.return_value = circuits |
| 272 |
|
|
| 273 |
|
api = self.get_app_test_client(self.napp) |
| 274 |
|
url = f'{self.server_name_url}/v2/evc/?archived=True' |
| 275 |
|
|
| 276 |
|
response = api.get(url) |
| 277 |
|
expected_result = circuits |
| 278 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 279 |
|
|
| 280 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 281 |
|
def test_circuit_with_valid_id(self, storehouse_data_mock): |
|
@@ 252-264 (lines=13) @@
|
| 249 |
|
expected_result = circuits |
| 250 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 251 |
|
|
| 252 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 253 |
|
def test_list_with_archived_circuits_stored_1(self, storehouse_data_mock): |
| 254 |
|
"""Test if list circuits return only circuits not archived.""" |
| 255 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 256 |
|
'2': {'name': 'circuit_2', 'archived': True}} |
| 257 |
|
storehouse_data_mock.return_value = circuits |
| 258 |
|
|
| 259 |
|
api = self.get_app_test_client(self.napp) |
| 260 |
|
url = f'{self.server_name_url}/v2/evc/' |
| 261 |
|
|
| 262 |
|
response = api.get(url) |
| 263 |
|
expected_result = {'1': circuits['1']} |
| 264 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 265 |
|
|
| 266 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 267 |
|
def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock): |
|
@@ 280-291 (lines=12) @@
|
| 277 |
|
expected_result = circuits |
| 278 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 279 |
|
|
| 280 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 281 |
|
def test_circuit_with_valid_id(self, storehouse_data_mock): |
| 282 |
|
"""Test if get_circuit return the circuit attributes.""" |
| 283 |
|
circuits = {'1': {'name': 'circuit_1'}, |
| 284 |
|
'2': {'name': 'circuit_2'}} |
| 285 |
|
storehouse_data_mock.return_value = circuits |
| 286 |
|
|
| 287 |
|
api = self.get_app_test_client(self.napp) |
| 288 |
|
url = f'{self.server_name_url}/v2/evc/1' |
| 289 |
|
response = api.get(url) |
| 290 |
|
expected_result = circuits['1'] |
| 291 |
|
self.assertEqual(json.loads(response.data), expected_result) |
| 292 |
|
|
| 293 |
|
@patch('napps.kytos.mef_eline.storehouse.StoreHouse.get_data') |
| 294 |
|
def test_circuit_with_invalid_id(self, storehouse_data_mock): |