|
@@ 351-369 (lines=19) @@
|
| 348 |
|
with pytest.raises(InvalidPath): |
| 349 |
|
path.is_valid(switch1, switch5) |
| 350 |
|
|
| 351 |
|
def test_is_valid_invalid(self): |
| 352 |
|
"""Test is_valid when path is invalid |
| 353 |
|
UNI_Z is not connected""" |
| 354 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 355 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 356 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 357 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 358 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 359 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 360 |
|
links = [ |
| 361 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 362 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 363 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 364 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 365 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 366 |
|
] |
| 367 |
|
path = Path(links) |
| 368 |
|
with pytest.raises(InvalidPath): |
| 369 |
|
path.is_valid(switch3, switch6) |
| 370 |
|
|
| 371 |
|
|
| 372 |
|
class TestDynamicPathManager(): |
|
@@ 299-316 (lines=18) @@
|
| 296 |
|
path = Path([]) |
| 297 |
|
assert path.is_valid(MagicMock(), MagicMock(), False) |
| 298 |
|
|
| 299 |
|
def test_is_valid(self): |
| 300 |
|
"""Test is_valid method.""" |
| 301 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 302 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 303 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 304 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 305 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 306 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 307 |
|
# Links connected |
| 308 |
|
links = [ |
| 309 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 310 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 311 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 312 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 313 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 314 |
|
] |
| 315 |
|
path = Path(links) |
| 316 |
|
assert path.is_valid(switch6, switch1) is True |
| 317 |
|
|
| 318 |
|
def test_is_valid_diconnected(self): |
| 319 |
|
"""Test is_valid with disconnected path""" |