|
@@ 253-271 (lines=19) @@
|
| 250 |
|
with pytest.raises(InvalidPath): |
| 251 |
|
path.is_valid(switch1, switch5) |
| 252 |
|
|
| 253 |
|
def test_is_valid_invalid(self): |
| 254 |
|
"""Test is_valid when path is invalid |
| 255 |
|
UNI_Z is not connected""" |
| 256 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 257 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 258 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 259 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 260 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 261 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 262 |
|
links = [ |
| 263 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 264 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 265 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 266 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 267 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 268 |
|
] |
| 269 |
|
path = Path(links) |
| 270 |
|
with pytest.raises(InvalidPath): |
| 271 |
|
path.is_valid(switch3, switch6) |
| 272 |
|
|
| 273 |
|
|
| 274 |
|
class TestDynamicPathManager(): |
|
@@ 201-218 (lines=18) @@
|
| 198 |
|
path = Path([]) |
| 199 |
|
assert path.is_valid(MagicMock(), MagicMock(), False) |
| 200 |
|
|
| 201 |
|
def test_is_valid(self): |
| 202 |
|
"""Test is_valid method.""" |
| 203 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 204 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 205 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 206 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 207 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 208 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 209 |
|
# Links connected |
| 210 |
|
links = [ |
| 211 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 212 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 213 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 214 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 215 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 216 |
|
] |
| 217 |
|
path = Path(links) |
| 218 |
|
assert path.is_valid(switch6, switch1) is True |
| 219 |
|
|
| 220 |
|
def test_is_valid_diconnected(self): |
| 221 |
|
"""Test is_valid with disconnected path""" |