|
@@ 193-235 (lines=43) @@
|
| 190 |
|
msg = f"{evc} deployed after link down." |
| 191 |
|
log_mocked.debug.assert_called_once_with(msg) |
| 192 |
|
|
| 193 |
|
@patch('napps.kytos.mef_eline.models.log') |
| 194 |
|
@patch('napps.kytos.mef_eline.models.EVCDeploy.deploy') |
| 195 |
|
@patch('napps.kytos.mef_eline.models.LinkProtection.deploy_to') |
| 196 |
|
def test_handle_link_down_case_2(self, deploy_to_mocked, deploy_mocked, |
| 197 |
|
log_mocked): |
| 198 |
|
"""Test if deploy_to backup path is called.""" |
| 199 |
|
deploy_mocked.return_value = True |
| 200 |
|
deploy_to_mocked.return_value = True |
| 201 |
|
primary_path = [ |
| 202 |
|
get_link_mocked(endpoint_a_port=9, endpoint_b_port=10, |
| 203 |
|
metadata={"s_vlan": 5}, |
| 204 |
|
status=EntityStatus.UP), |
| 205 |
|
get_link_mocked(endpoint_a_port=11, endpoint_b_port=12, |
| 206 |
|
metadata={"s_vlan": 6}, |
| 207 |
|
status=EntityStatus.UP), |
| 208 |
|
] |
| 209 |
|
backup_path = [ |
| 210 |
|
get_link_mocked(endpoint_a_port=9, endpoint_b_port=10, |
| 211 |
|
metadata={"s_vlan": 5}, |
| 212 |
|
status=EntityStatus.DOWN), |
| 213 |
|
get_link_mocked(endpoint_a_port=11, endpoint_b_port=12, |
| 214 |
|
metadata={"s_vlan": 6}, |
| 215 |
|
status=EntityStatus.UP), |
| 216 |
|
] |
| 217 |
|
attributes = { |
| 218 |
|
"controller": get_controller_mock(), |
| 219 |
|
"name": "circuit_name", |
| 220 |
|
"uni_a": get_uni_mocked(is_valid=True), |
| 221 |
|
"uni_z": get_uni_mocked(is_valid=True), |
| 222 |
|
"primary_path": primary_path, |
| 223 |
|
"backup_path": backup_path, |
| 224 |
|
"enabled": True |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
evc = EVC(**attributes) |
| 228 |
|
evc.current_path = evc.backup_path |
| 229 |
|
current_handle_link_down = evc.handle_link_down() |
| 230 |
|
self.assertEqual(deploy_mocked.call_count, 0) |
| 231 |
|
deploy_to_mocked.assert_called_once_with('primary_path', |
| 232 |
|
evc.primary_path) |
| 233 |
|
self.assertTrue(current_handle_link_down) |
| 234 |
|
msg = f"{evc} deployed after link down." |
| 235 |
|
log_mocked.debug.assert_called_once_with(msg) |
| 236 |
|
|
| 237 |
|
@patch('napps.kytos.mef_eline.models.log') |
| 238 |
|
@patch('napps.kytos.mef_eline.models.EVCDeploy.deploy') |
|
@@ 341-379 (lines=39) @@
|
| 338 |
|
msg = f"{evc} deployed after link down." |
| 339 |
|
log_mocked.debug.assert_called_with(msg) |
| 340 |
|
|
| 341 |
|
@patch('napps.kytos.mef_eline.models.EVCDeploy.deploy') |
| 342 |
|
@patch('napps.kytos.mef_eline.models.LinkProtection.deploy_to') |
| 343 |
|
def test_handle_link_up_case_1(self, deploy_to_mocked, deploy_mocked): |
| 344 |
|
"""Test if handle link up do nothing when is using primary path.""" |
| 345 |
|
deploy_mocked.return_value = True |
| 346 |
|
deploy_to_mocked.return_value = True |
| 347 |
|
primary_path = [ |
| 348 |
|
get_link_mocked(endpoint_a_port=9, endpoint_b_port=10, |
| 349 |
|
metadata={"s_vlan": 5}, |
| 350 |
|
status=EntityStatus.UP), |
| 351 |
|
get_link_mocked(endpoint_a_port=11, endpoint_b_port=12, |
| 352 |
|
metadata={"s_vlan": 6}, |
| 353 |
|
status=EntityStatus.UP), |
| 354 |
|
] |
| 355 |
|
backup_path = [ |
| 356 |
|
get_link_mocked(endpoint_a_port=9, endpoint_b_port=10, |
| 357 |
|
metadata={"s_vlan": 5}, |
| 358 |
|
status=EntityStatus.UP), |
| 359 |
|
get_link_mocked(endpoint_a_port=11, endpoint_b_port=12, |
| 360 |
|
metadata={"s_vlan": 6}, |
| 361 |
|
status=EntityStatus.UP), |
| 362 |
|
] |
| 363 |
|
attributes = { |
| 364 |
|
"controller": get_controller_mock(), |
| 365 |
|
"name": "circuit_name", |
| 366 |
|
"uni_a": get_uni_mocked(is_valid=True), |
| 367 |
|
"uni_z": get_uni_mocked(is_valid=True), |
| 368 |
|
"primary_path": primary_path, |
| 369 |
|
"backup_path": backup_path, |
| 370 |
|
"enabled": True, |
| 371 |
|
"dynamic_backup_path": True |
| 372 |
|
} |
| 373 |
|
|
| 374 |
|
evc = EVC(**attributes) |
| 375 |
|
evc.current_path = evc.primary_path |
| 376 |
|
current_handle_link_up = evc.handle_link_up(backup_path[0]) |
| 377 |
|
self.assertEqual(deploy_mocked.call_count, 0) |
| 378 |
|
self.assertEqual(deploy_to_mocked.call_count, 0) |
| 379 |
|
self.assertTrue(current_handle_link_up) |
| 380 |
|
|
| 381 |
|
@patch('napps.kytos.mef_eline.models.EVCDeploy.deploy') |
| 382 |
|
@patch('napps.kytos.mef_eline.models.LinkProtection.deploy_to') |