|
@@ 242-260 (lines=19) @@
|
| 239 |
|
with pytest.raises(InvalidPath): |
| 240 |
|
path.is_valid(switch1, switch5) |
| 241 |
|
|
| 242 |
|
def test_is_valid_invalid(self): |
| 243 |
|
"""Test is_valid when path is invalid |
| 244 |
|
UNI_Z is not connected""" |
| 245 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 246 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 247 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 248 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 249 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 250 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 251 |
|
links = [ |
| 252 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 253 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 254 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 255 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 256 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 257 |
|
] |
| 258 |
|
path = Path(links) |
| 259 |
|
with pytest.raises(InvalidPath): |
| 260 |
|
path.is_valid(switch3, switch6) |
| 261 |
|
|
| 262 |
|
|
| 263 |
|
class TestDynamicPathManager(): |
|
@@ 190-207 (lines=18) @@
|
| 187 |
|
path = Path([]) |
| 188 |
|
assert path.is_valid(MagicMock(), MagicMock(), False) |
| 189 |
|
|
| 190 |
|
def test_is_valid(self): |
| 191 |
|
"""Test is_valid method.""" |
| 192 |
|
switch1 = Switch("00:00:00:00:00:00:00:01") |
| 193 |
|
switch2 = Switch("00:00:00:00:00:00:00:02") |
| 194 |
|
switch3 = Switch("00:00:00:00:00:00:00:03") |
| 195 |
|
switch4 = Switch("00:00:00:00:00:00:00:04") |
| 196 |
|
switch5 = Switch("00:00:00:00:00:00:00:05") |
| 197 |
|
switch6 = Switch("00:00:00:00:00:00:00:06") |
| 198 |
|
# Links connected |
| 199 |
|
links = [ |
| 200 |
|
get_link_mocked(switch_a=switch5, switch_b=switch6), |
| 201 |
|
get_link_mocked(switch_a=switch4, switch_b=switch5), |
| 202 |
|
get_link_mocked(switch_a=switch3, switch_b=switch4), |
| 203 |
|
get_link_mocked(switch_a=switch2, switch_b=switch3), |
| 204 |
|
get_link_mocked(switch_a=switch1, switch_b=switch2), |
| 205 |
|
] |
| 206 |
|
path = Path(links) |
| 207 |
|
assert path.is_valid(switch6, switch1) is True |
| 208 |
|
|
| 209 |
|
def test_is_valid_diconnected(self): |
| 210 |
|
"""Test is_valid with disconnected path""" |