|
@@ 281-299 (lines=19) @@
|
| 278 |
|
with pytest.raises(InvalidPath): |
| 279 |
|
path.is_valid(switch1, switch5) |
| 280 |
|
|
| 281 |
|
def test_is_valid_invalid(self): |
| 282 |
|
"""Test is_valid when path is invalid |
| 283 |
|
UNI_Z is not connected""" |
| 284 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 285 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 286 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 287 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 288 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 289 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 290 |
|
links = [ |
| 291 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 292 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 293 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 294 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 295 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 296 |
|
] |
| 297 |
|
path = Path(links) |
| 298 |
|
with pytest.raises(InvalidPath): |
| 299 |
|
path.is_valid(switch3, switch6) |
| 300 |
|
|
| 301 |
|
|
| 302 |
|
class TestDynamicPathManager(): |
|
@@ 229-246 (lines=18) @@
|
| 226 |
|
path = Path([]) |
| 227 |
|
assert path.is_valid(MagicMock(), MagicMock(), False) |
| 228 |
|
|
| 229 |
|
def test_is_valid(self): |
| 230 |
|
"""Test is_valid method.""" |
| 231 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 232 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 233 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 234 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 235 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 236 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 237 |
|
# Links connected |
| 238 |
|
links = [ |
| 239 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 240 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 241 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 242 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 243 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 244 |
|
] |
| 245 |
|
path = Path(links) |
| 246 |
|
assert path.is_valid(switch6, switch1) is True |
| 247 |
|
|
| 248 |
|
def test_is_valid_diconnected(self): |
| 249 |
|
"""Test is_valid with disconnected path""" |