| Total Complexity | 50 | 
| Total Lines | 509 | 
| Duplicated Lines | 8.64 % | 
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like build.tests.unit.test_results_edges often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | """Module to test the KytosGraph in graph.py.""" | ||
| 2 | from itertools import combinations | ||
| 3 | |||
| 4 | # Core modules to import | ||
| 5 | from kytos.core.link import Link | ||
| 6 | |||
| 7 | # module under test | ||
| 8 | from tests.unit.test_results import TestResults | ||
| 9 | |||
| 10 | |||
| 11 | class TestResultsEdges(TestResults): | ||
| 12 | """Tests for the graph class. | ||
| 13 | |||
| 14 | Tests to see if reflexive searches and impossible searches | ||
| 15 | show correct results. | ||
| 16 | """ | ||
| 17 | |||
| 18 | def test_path1(self): | ||
| 19 | """Tests paths between all users using unconstrained path alogrithm.""" | ||
| 20 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 21 | for point_a, point_b in combos: | ||
| 22 | results = self.get_path(point_a, point_b) | ||
| 23 | self.assertNotEqual(results, []) | ||
| 24 | |||
| 25 | def test_path2(self): | ||
| 26 | """Tests paths between all users using constrained path algorithm, | ||
| 27 | with no constraints set.""" | ||
| 28 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 29 | for point_a, point_b in combos: | ||
| 30 | results = self.get_path_constrained(point_a, point_b) | ||
| 31 | self.assertNotEqual(results, []) | ||
| 32 | |||
| 33 | def test_path3(self): | ||
| 34 | """Tests paths between all users using constrained path algorithm, | ||
| 35 | with the ownership constraint set to B.""" | ||
| 36 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 37 | for point_a, point_b in combos: | ||
| 38 | results = self.get_path_constrained( | ||
| 39 | point_a, point_b, base=dict(ownership="B")) | ||
| 40 | for result in results: | ||
| 41 | for path in result["paths"]: | ||
| 42 |                     self.assertNotIn("S4:1", path) | ||
| 43 |                     self.assertNotIn("S5:2", path) | ||
| 44 |                     self.assertNotIn("S4:2", path) | ||
| 45 |                     self.assertNotIn("User1:2", path) | ||
| 46 |                     self.assertNotIn("S5:4", path) | ||
| 47 |                     self.assertNotIn("S6:2", path) | ||
| 48 |                     self.assertNotIn("S6:5", path) | ||
| 49 |                     self.assertNotIn("S10:1", path) | ||
| 50 |                     self.assertNotIn("S8:6", path) | ||
| 51 |                     self.assertNotIn("S10:2", path) | ||
| 52 |                     self.assertNotIn("S10:3", path) | ||
| 53 |                     self.assertNotIn("User2:1", path) | ||
| 54 | |||
| 55 | def test_path4(self): | ||
| 56 | """Tests paths between all users using constrained path algorithm, | ||
| 57 | with the reliability constraint set to 3.""" | ||
| 58 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 59 | for point_a, point_b in combos: | ||
| 60 | results = self.get_path_constrained( | ||
| 61 | point_a, point_b, base=dict(reliability=3)) | ||
| 62 | for result in results: | ||
| 63 | for path in result["paths"]: | ||
| 64 |                     self.assertNotIn("S4:1", path) | ||
| 65 |                     self.assertNotIn("S5:2", path) | ||
| 66 |                     self.assertNotIn("S5:3", path) | ||
| 67 |                     self.assertNotIn("S6:1", path) | ||
| 68 | |||
| 69 | def test_path5(self): | ||
| 70 | """Tests paths between all users using constrained path algorithm, | ||
| 71 | with the bandwidth contraint set to 100.""" | ||
| 72 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 73 | for point_a, point_b in combos: | ||
| 74 | results = self.get_path_constrained( | ||
| 75 | point_a, point_b, base=dict(bandwidth=100)) | ||
| 76 | for result in results: | ||
| 77 | for path in result["paths"]: | ||
| 78 |                     self.assertNotIn("S3:1", path) | ||
| 79 |                     self.assertNotIn("S5:1", path) | ||
| 80 |                     self.assertNotIn("User1:4", path) | ||
| 81 |                     self.assertNotIn("User4:3", path) | ||
| 82 | |||
| 83 | def test_path6(self): | ||
| 84 | """Tests paths between all users using constrained path algorithm, | ||
| 85 | with the delay constraint set to 50.""" | ||
| 86 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 87 | for point_a, point_b in combos: | ||
| 88 | results = self.get_path_constrained( | ||
| 89 | point_a, point_b, base=dict(delay=50)) | ||
| 90 | for result in results: | ||
| 91 | for path in result["paths"]: | ||
| 92 |                     self.assertNotIn("S1:1", path) | ||
| 93 |                     self.assertNotIn("S2:1", path) | ||
| 94 |                     self.assertNotIn("S3:1", path) | ||
| 95 |                     self.assertNotIn("S5:1", path) | ||
| 96 |                     self.assertNotIn("S4:2", path) | ||
| 97 |                     self.assertNotIn("User1:2", path) | ||
| 98 |                     self.assertNotIn("S5:5", path) | ||
| 99 |                     self.assertNotIn("S8:2", path) | ||
| 100 |                     self.assertNotIn("S5:6", path) | ||
| 101 |                     self.assertNotIn("User1:3", path) | ||
| 102 |                     self.assertNotIn("S6:3", path) | ||
| 103 |                     self.assertNotIn("S9:1", path) | ||
| 104 |                     self.assertNotIn("S6:4", path) | ||
| 105 |                     self.assertNotIn("S9:2", path) | ||
| 106 |                     self.assertNotIn("S6:5", path) | ||
| 107 |                     self.assertNotIn("S10:1", path) | ||
| 108 |                     self.assertNotIn("S8:5", path) | ||
| 109 |                     self.assertNotIn("S9:4", path) | ||
| 110 |                     self.assertNotIn("User1:4", path) | ||
| 111 |                     self.assertNotIn("User4:3", path) | ||
| 112 | |||
| 113 | def test_path7(self): | ||
| 114 | """Tests paths between all users using constrained path algorithm, | ||
| 115 | with the delay constraint set to 50, the bandwidth constraint set | ||
| 116 | to 100, the reliability contraint set to 3, and the ownership | ||
| 117 | constraint set to 'B' """ | ||
| 118 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 119 | for point_a, point_b in combos: | ||
| 120 | results = self.get_path_constrained( | ||
| 121 | point_a, point_b, base=dict(delay=50, bandwidth=100, | ||
| 122 | reliability=3, | ||
| 123 | ownership="B")) | ||
| 124 | for result in results: | ||
| 125 | for path in result["paths"]: | ||
| 126 | # delay = 50 checks | ||
| 127 |                     self.assertNotIn("S1:1", path) | ||
| 128 |                     self.assertNotIn("S2:1", path) | ||
| 129 |                     self.assertNotIn("S3:1", path) | ||
| 130 |                     self.assertNotIn("S5:1", path) | ||
| 131 |                     self.assertNotIn("S4:2", path) | ||
| 132 |                     self.assertNotIn("User1:2", path) | ||
| 133 |                     self.assertNotIn("S5:5", path) | ||
| 134 |                     self.assertNotIn("S8:2", path) | ||
| 135 |                     self.assertNotIn("S5:6", path) | ||
| 136 |                     self.assertNotIn("User1:3", path) | ||
| 137 |                     self.assertNotIn("S6:3", path) | ||
| 138 |                     self.assertNotIn("S9:1", path) | ||
| 139 |                     self.assertNotIn("S6:4", path) | ||
| 140 |                     self.assertNotIn("S9:2", path) | ||
| 141 |                     self.assertNotIn("S6:5", path) | ||
| 142 |                     self.assertNotIn("S10:1", path) | ||
| 143 |                     self.assertNotIn("S8:5", path) | ||
| 144 |                     self.assertNotIn("S9:4", path) | ||
| 145 |                     self.assertNotIn("User1:4", path) | ||
| 146 |                     self.assertNotIn("User4:3", path) | ||
| 147 | |||
| 148 | # bandwidth = 100 checks | ||
| 149 | |||
| 150 |                     self.assertNotIn("S3:1", path) | ||
| 151 |                     self.assertNotIn("S5:1", path) | ||
| 152 |                     self.assertNotIn("User1:4", path) | ||
| 153 |                     self.assertNotIn("User4:3", path) | ||
| 154 | |||
| 155 | # reliability = 3 checks | ||
| 156 | |||
| 157 |                     self.assertNotIn("S4:1", path) | ||
| 158 |                     self.assertNotIn("S5:2", path) | ||
| 159 |                     self.assertNotIn("S5:3", path) | ||
| 160 |                     self.assertNotIn("S6:1", path) | ||
| 161 | |||
| 162 | # ownership = "B" checks | ||
| 163 | |||
| 164 |                     self.assertNotIn("S4:1", path) | ||
| 165 |                     self.assertNotIn("S5:2", path) | ||
| 166 |                     self.assertNotIn("S4:2", path) | ||
| 167 |                     self.assertNotIn("User1:2", path) | ||
| 168 |                     self.assertNotIn("S5:4", path) | ||
| 169 |                     self.assertNotIn("S6:2", path) | ||
| 170 |                     self.assertNotIn("S6:5", path) | ||
| 171 |                     self.assertNotIn("S10:1", path) | ||
| 172 |                     self.assertNotIn("S8:6", path) | ||
| 173 |                     self.assertNotIn("S10:2", path) | ||
| 174 |                     self.assertNotIn("S10:3", path) | ||
| 175 |                     self.assertNotIn("User2:1", path) | ||
| 176 | |||
| 177 | def test_path8(self): | ||
| 178 | """Tests paths between all users using constrained path algorithm, | ||
| 179 | with the delay constraint set to 50, the bandwidth constraint | ||
| 180 | set to 100, the reliability contraint set to 3, and the ownership | ||
| 181 | constraint set to 'B' | ||
| 182 | |||
| 183 | Tests conducted with flexibility enabled""" | ||
| 184 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 185 | for point_a, point_b in combos: | ||
| 186 | results = self.get_path_constrained( | ||
| 187 | point_a, point_b, flexible=dict(delay=50, bandwidth=100, | ||
| 188 | reliability=3, | ||
| 189 | ownership="B")) | ||
| 190 | for result in results: | ||
| 191 | # delay = 50 checks | ||
| 192 | View Code Duplication | if "delay" in result["metrics"]: | |
|  | |||
| 193 | for path in result["paths"]: | ||
| 194 |                         self.assertNotIn("S1:1", path) | ||
| 195 |                         self.assertNotIn("S2:1", path) | ||
| 196 |                         self.assertNotIn("S3:1", path) | ||
| 197 |                         self.assertNotIn("S5:1", path) | ||
| 198 |                         self.assertNotIn("S4:2", path) | ||
| 199 |                         self.assertNotIn("User1:2", path) | ||
| 200 |                         self.assertNotIn("S5:5", path) | ||
| 201 |                         self.assertNotIn("S8:2", path) | ||
| 202 |                         self.assertNotIn("S5:6", path) | ||
| 203 |                         self.assertNotIn("User1:3", path) | ||
| 204 |                         self.assertNotIn("S6:3", path) | ||
| 205 |                         self.assertNotIn("S9:1", path) | ||
| 206 |                         self.assertNotIn("S6:4", path) | ||
| 207 |                         self.assertNotIn("S9:2", path) | ||
| 208 |                         self.assertNotIn("S6:5", path) | ||
| 209 |                         self.assertNotIn("S10:1", path) | ||
| 210 |                         self.assertNotIn("S8:5", path) | ||
| 211 |                         self.assertNotIn("S9:4", path) | ||
| 212 |                         self.assertNotIn("User1:4", path) | ||
| 213 |                         self.assertNotIn("User4:3", path) | ||
| 214 | |||
| 215 | # bandwidth = 100 checks | ||
| 216 | if "bandwidth" in result["metrics"]: | ||
| 217 | for path in result["paths"]: | ||
| 218 |                         self.assertNotIn("S3:1", path) | ||
| 219 |                         self.assertNotIn("S5:1", path) | ||
| 220 |                         self.assertNotIn("User1:4", path) | ||
| 221 |                         self.assertNotIn("User4:3", path) | ||
| 222 | |||
| 223 | # reliability = 3 checks | ||
| 224 | if "reliability" in result["metrics"]: | ||
| 225 | for path in result["paths"]: | ||
| 226 |                         self.assertNotIn("S4:1", path) | ||
| 227 |                         self.assertNotIn("S5:2", path) | ||
| 228 |                         self.assertNotIn("S5:3", path) | ||
| 229 |                         self.assertNotIn("S6:1", path) | ||
| 230 | |||
| 231 | # ownership = "B" checks | ||
| 232 | if "ownership" in result["metrics"]: | ||
| 233 | for path in result["paths"]: | ||
| 234 |                         self.assertNotIn("S4:1", path) | ||
| 235 |                         self.assertNotIn("S5:2", path) | ||
| 236 |                         self.assertNotIn("S4:2", path) | ||
| 237 |                         self.assertNotIn("User1:2", path) | ||
| 238 |                         self.assertNotIn("S5:4", path) | ||
| 239 |                         self.assertNotIn("S6:2", path) | ||
| 240 |                         self.assertNotIn("S6:5", path) | ||
| 241 |                         self.assertNotIn("S10:1", path) | ||
| 242 |                         self.assertNotIn("S8:6", path) | ||
| 243 |                         self.assertNotIn("S10:2", path) | ||
| 244 |                         self.assertNotIn("S10:3", path) | ||
| 245 |                         self.assertNotIn("User2:1", path) | ||
| 246 | |||
| 247 | def test_path9(self): | ||
| 248 | """Tests paths between all users using constrained path algorithm, | ||
| 249 | with the delay constraint set to 50, the bandwidth constraint | ||
| 250 | set to 100, the reliability contraint set to 3, and the ownership | ||
| 251 | constraint set to 'B' | ||
| 252 | |||
| 253 | Tests conducted with all but ownership flexible""" | ||
| 254 | combos = combinations(["User1", "User2", "User3", "User4"], 2) | ||
| 255 | for point_a, point_b in combos: | ||
| 256 | results = self.get_path_constrained(point_a, point_b, | ||
| 257 |                                                 base={"ownership": "B"}, | ||
| 258 |                                                 flexible={"delay": 50, | ||
| 259 | "bandwidth": 100, | ||
| 260 | "reliability": 3}) | ||
| 261 | for result in results: | ||
| 262 | # delay = 50 checks | ||
| 263 | View Code Duplication | if "delay" in result["metrics"]: | |
| 264 | for path in result["paths"]: | ||
| 265 |                         self.assertNotIn("S1:1", path) | ||
| 266 |                         self.assertNotIn("S2:1", path) | ||
| 267 |                         self.assertNotIn("S3:1", path) | ||
| 268 |                         self.assertNotIn("S5:1", path) | ||
| 269 |                         self.assertNotIn("S4:2", path) | ||
| 270 |                         self.assertNotIn("User1:2", path) | ||
| 271 |                         self.assertNotIn("S5:5", path) | ||
| 272 |                         self.assertNotIn("S8:2", path) | ||
| 273 |                         self.assertNotIn("S5:6", path) | ||
| 274 |                         self.assertNotIn("User1:3", path) | ||
| 275 |                         self.assertNotIn("S6:3", path) | ||
| 276 |                         self.assertNotIn("S9:1", path) | ||
| 277 |                         self.assertNotIn("S6:4", path) | ||
| 278 |                         self.assertNotIn("S9:2", path) | ||
| 279 |                         self.assertNotIn("S6:5", path) | ||
| 280 |                         self.assertNotIn("S10:1", path) | ||
| 281 |                         self.assertNotIn("S8:5", path) | ||
| 282 |                         self.assertNotIn("S9:4", path) | ||
| 283 |                         self.assertNotIn("User1:4", path) | ||
| 284 |                         self.assertNotIn("User4:3", path) | ||
| 285 | |||
| 286 | # bandwidth = 100 checks | ||
| 287 | if "bandwidth" in result["metrics"]: | ||
| 288 | for path in result["paths"]: | ||
| 289 |                         self.assertNotIn("S3:1", path) | ||
| 290 |                         self.assertNotIn("S5:1", path) | ||
| 291 |                         self.assertNotIn("User1:4", path) | ||
| 292 |                         self.assertNotIn("User4:3", path) | ||
| 293 | |||
| 294 | # reliability = 3 checks | ||
| 295 | if "reliability" in result["metrics"]: | ||
| 296 | for path in result["paths"]: | ||
| 297 |                         self.assertNotIn("S4:1", path) | ||
| 298 |                         self.assertNotIn("S5:2", path) | ||
| 299 |                         self.assertNotIn("S5:3", path) | ||
| 300 |                         self.assertNotIn("S6:1", path) | ||
| 301 | |||
| 302 | # ownership = "B" checks | ||
| 303 |                 self.assertIn("ownership", result["metrics"]) | ||
| 304 | for path in result["paths"]: | ||
| 305 |                     self.assertNotIn("S4:1", path) | ||
| 306 |                     self.assertNotIn("S5:2", path) | ||
| 307 |                     self.assertNotIn("S4:2", path) | ||
| 308 |                     self.assertNotIn("User1:2", path) | ||
| 309 |                     self.assertNotIn("S5:4", path) | ||
| 310 |                     self.assertNotIn("S6:2", path) | ||
| 311 |                     self.assertNotIn("S6:5", path) | ||
| 312 |                     self.assertNotIn("S10:1", path) | ||
| 313 |                     self.assertNotIn("S8:6", path) | ||
| 314 |                     self.assertNotIn("S10:2", path) | ||
| 315 |                     self.assertNotIn("S10:3", path) | ||
| 316 |                     self.assertNotIn("User2:1", path) | ||
| 317 | |||
| 318 | def test_path10(self): | ||
| 319 | """Tests that TypeError is generated by get_path_constrained | ||
| 320 | |||
| 321 | Tests with ownership using an int type rather than string""" | ||
| 322 | with self.assertRaises(TypeError): | ||
| 323 | self.get_path_constrained( | ||
| 324 |                 "User1", "User2", base={"ownership": 1}) | ||
| 325 | |||
| 326 | @ staticmethod | ||
| 327 | def generate_topology(): | ||
| 328 | """Generates a predetermined topology""" | ||
| 329 |         switches = {} | ||
| 330 |         interfaces = {} | ||
| 331 |         links = {} | ||
| 332 | |||
| 333 |         TestResults.create_switch("S1", switches) | ||
| 334 | TestResults.add_interfaces(2, switches["S1"], interfaces) | ||
| 335 | |||
| 336 |         TestResults.create_switch("S2", switches) | ||
| 337 | TestResults.add_interfaces(2, switches["S2"], interfaces) | ||
| 338 | |||
| 339 |         TestResults.create_switch("S3", switches) | ||
| 340 | TestResults.add_interfaces(6, switches["S3"], interfaces) | ||
| 341 | |||
| 342 |         TestResults.create_switch("S4", switches) | ||
| 343 | TestResults.add_interfaces(2, switches["S4"], interfaces) | ||
| 344 | |||
| 345 |         TestResults.create_switch("S5", switches) | ||
| 346 | TestResults.add_interfaces(6, switches["S5"], interfaces) | ||
| 347 | |||
| 348 |         TestResults.create_switch("S6", switches) | ||
| 349 | TestResults.add_interfaces(5, switches["S6"], interfaces) | ||
| 350 | |||
| 351 |         TestResults.create_switch("S7", switches) | ||
| 352 | TestResults.add_interfaces(2, switches["S7"], interfaces) | ||
| 353 | |||
| 354 |         TestResults.create_switch("S8", switches) | ||
| 355 | TestResults.add_interfaces(8, switches["S8"], interfaces) | ||
| 356 | |||
| 357 |         TestResults.create_switch("S9", switches) | ||
| 358 | TestResults.add_interfaces(4, switches["S9"], interfaces) | ||
| 359 | |||
| 360 |         TestResults.create_switch("S10", switches) | ||
| 361 | TestResults.add_interfaces(3, switches["S10"], interfaces) | ||
| 362 | |||
| 363 |         TestResults.create_switch("S11", switches) | ||
| 364 | TestResults.add_interfaces(3, switches["S11"], interfaces) | ||
| 365 | |||
| 366 |         TestResults.create_switch("User1", switches) | ||
| 367 | TestResults.add_interfaces(4, switches["User1"], interfaces) | ||
| 368 | |||
| 369 |         TestResults.create_switch("User2", switches) | ||
| 370 | TestResults.add_interfaces(2, switches["User2"], interfaces) | ||
| 371 | |||
| 372 |         TestResults.create_switch("User3", switches) | ||
| 373 | TestResults.add_interfaces(2, switches["User3"], interfaces) | ||
| 374 | |||
| 375 |         TestResults.create_switch("User4", switches) | ||
| 376 | TestResults.add_interfaces(3, switches["User4"], interfaces) | ||
| 377 | |||
| 378 | TestResultsEdges._fill_links(links, interfaces) | ||
| 379 | TestResultsEdges._add_metadata_to_links(links) | ||
| 380 | |||
| 381 | return (switches, links) | ||
| 382 | |||
| 383 | @ staticmethod | ||
| 384 | def _add_metadata_to_links(links): | ||
| 385 | links["S1:1<->S2:1"].extend_metadata( | ||
| 386 |             {"reliability": 5, "bandwidth": 100, "delay": 105}) | ||
| 387 | links["S1:2<->User1:1"].extend_metadata( | ||
| 388 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | ||
| 389 | links["S2:2<->User4:1"].extend_metadata( | ||
| 390 |             {"reliability": 5, "bandwidth": 100, "delay": 10}) | ||
| 391 | links["S3:1<->S5:1"].extend_metadata( | ||
| 392 |             {"reliability": 5, "bandwidth": 10, "delay": 112}) | ||
| 393 | links["S3:2<->S7:1"].extend_metadata( | ||
| 394 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | ||
| 395 | links["S3:3<->S8:1"].extend_metadata( | ||
| 396 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | ||
| 397 | links["S3:4<->S11:1"].extend_metadata( | ||
| 398 |             {"reliability": 3, "bandwidth": 100, "delay": 6}) | ||
| 399 | links["S3:5<->User3:1"].extend_metadata( | ||
| 400 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | ||
| 401 | links["S3:6<->User4:2"].extend_metadata( | ||
| 402 |             {"reliability": 5, "bandwidth": 100, "delay": 10}) | ||
| 403 | links["S4:1<->S5:2"].extend_metadata( | ||
| 404 |             {"reliability": 1, "bandwidth": 100, "delay": 30, | ||
| 405 | "ownership": "A"}) | ||
| 406 | links["S4:2<->User1:2"].extend_metadata( | ||
| 407 |             {"reliability": 3, "bandwidth": 100, "delay": 110, | ||
| 408 | "ownership": "A"}) | ||
| 409 | links["S5:3<->S6:1"].extend_metadata( | ||
| 410 |             {"reliability": 1, "bandwidth": 100, "delay": 40}) | ||
| 411 | links["S5:4<->S6:2"].extend_metadata( | ||
| 412 |             {"reliability": 3, "bandwidth": 100, "delay": 40, | ||
| 413 | "ownership": "A"}) | ||
| 414 | links["S5:5<->S8:2"].extend_metadata( | ||
| 415 |             {"reliability": 5, "bandwidth": 100, "delay": 112}) | ||
| 416 | links["S5:6<->User1:3"].extend_metadata( | ||
| 417 |             {"reliability": 3, "bandwidth": 100, "delay": 60}) | ||
| 418 | links["S6:3<->S9:1"].extend_metadata( | ||
| 419 |             {"reliability": 3, "bandwidth": 100, "delay": 60}) | ||
| 420 | links["S6:4<->S9:2"].extend_metadata( | ||
| 421 |             {"reliability": 5, "bandwidth": 100, "delay": 62}) | ||
| 422 | links["S6:5<->S10:1"].extend_metadata( | ||
| 423 |             {"bandwidth": 100, "delay": 108, "ownership": "A"}) | ||
| 424 | links["S7:2<->S8:3"].extend_metadata( | ||
| 425 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | ||
| 426 | links["S8:4<->S9:3"].extend_metadata( | ||
| 427 |             {"reliability": 3, "bandwidth": 100, "delay": 32}) | ||
| 428 | links["S8:5<->S9:4"].extend_metadata( | ||
| 429 |             {"reliability": 3, "bandwidth": 100, "delay": 110}) | ||
| 430 | links["S8:6<->S10:2"].extend_metadata( | ||
| 431 |             {"reliability": 5, "bandwidth": 100, "ownership": "A"}) | ||
| 432 | links["S8:7<->S11:2"].extend_metadata( | ||
| 433 |             {"reliability": 3, "bandwidth": 100, "delay": 7}) | ||
| 434 | links["S8:8<->User3:2"].extend_metadata( | ||
| 435 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | ||
| 436 | links["S10:3<->User2:1"].extend_metadata( | ||
| 437 |             {"reliability": 3, "bandwidth": 100, "delay": 10, | ||
| 438 | "ownership": "A"}) | ||
| 439 | links["S11:3<->User2:2"].extend_metadata( | ||
| 440 |             {"reliability": 3, "bandwidth": 100, "delay": 6}) | ||
| 441 | links["User1:4<->User4:3"].extend_metadata( | ||
| 442 |             {"reliability": 5, "bandwidth": 10, "delay": 105}) | ||
| 443 | |||
| 444 | @ staticmethod | ||
| 445 | def _fill_links(links, interfaces): | ||
| 446 | links["S1:1<->S2:1"] = Link(interfaces["S1:1"], interfaces["S2:1"]) | ||
| 447 | |||
| 448 | links["S1:2<->User1:1"] = Link(interfaces["S1:2"], | ||
| 449 | interfaces["User1:1"]) | ||
| 450 | |||
| 451 | links["S2:2<->User4:1"] = Link(interfaces["S2:2"], | ||
| 452 | interfaces["User4:1"]) | ||
| 453 | |||
| 454 | links["S3:1<->S5:1"] = Link(interfaces["S3:1"], interfaces["S5:1"]) | ||
| 455 | |||
| 456 | links["S3:2<->S7:1"] = Link(interfaces["S3:2"], interfaces["S7:1"]) | ||
| 457 | |||
| 458 | links["S3:3<->S8:1"] = Link(interfaces["S3:3"], interfaces["S8:1"]) | ||
| 459 | |||
| 460 | links["S3:4<->S11:1"] = Link(interfaces["S3:4"], interfaces["S11:1"]) | ||
| 461 | |||
| 462 | links["S3:5<->User3:1"] = Link(interfaces["S3:5"], | ||
| 463 | interfaces["User3:1"]) | ||
| 464 | |||
| 465 | links["S3:6<->User4:2"] = Link(interfaces["S3:6"], | ||
| 466 | interfaces["User4:2"]) | ||
| 467 | |||
| 468 | links["S4:1<->S5:2"] = Link(interfaces["S4:1"], interfaces["S5:2"]) | ||
| 469 | |||
| 470 | links["S4:2<->User1:2"] = Link(interfaces["S4:2"], | ||
| 471 | interfaces["User1:2"]) | ||
| 472 | |||
| 473 | links["S5:3<->S6:1"] = Link(interfaces["S5:3"], interfaces["S6:1"]) | ||
| 474 | |||
| 475 | links["S5:4<->S6:2"] = Link(interfaces["S5:4"], interfaces["S6:2"]) | ||
| 476 | |||
| 477 | links["S5:5<->S8:2"] = Link(interfaces["S5:5"], interfaces["S8:2"]) | ||
| 478 | |||
| 479 | links["S5:6<->User1:3"] = Link(interfaces["S5:6"], | ||
| 480 | interfaces["User1:3"]) | ||
| 481 | |||
| 482 | links["S6:3<->S9:1"] = Link(interfaces["S6:3"], interfaces["S9:1"]) | ||
| 483 | |||
| 484 | links["S6:4<->S9:2"] = Link(interfaces["S6:4"], interfaces["S9:2"]) | ||
| 485 | |||
| 486 | links["S6:5<->S10:1"] = Link(interfaces["S6:5"], interfaces["S10:1"]) | ||
| 487 | |||
| 488 | links["S7:2<->S8:3"] = Link(interfaces["S7:2"], interfaces["S8:3"]) | ||
| 489 | |||
| 490 | links["S8:4<->S9:3"] = Link(interfaces["S8:4"], interfaces["S9:3"]) | ||
| 491 | |||
| 492 | links["S8:5<->S9:4"] = Link(interfaces["S8:5"], interfaces["S9:4"]) | ||
| 493 | |||
| 494 | links["S8:6<->S10:2"] = Link(interfaces["S8:6"], interfaces["S10:2"]) | ||
| 495 | |||
| 496 | links["S8:7<->S11:2"] = Link(interfaces["S8:7"], interfaces["S11:2"]) | ||
| 497 | |||
| 498 | links["S8:8<->User3:2"] = Link(interfaces["S8:8"], | ||
| 499 | interfaces["User3:2"]) | ||
| 500 | |||
| 501 | links["S10:3<->User2:1"] = Link(interfaces["S10:3"], | ||
| 502 | interfaces["User2:1"]) | ||
| 503 | |||
| 504 | links["S11:3<->User2:2"] = Link(interfaces["S11:3"], | ||
| 505 | interfaces["User2:2"]) | ||
| 506 | |||
| 507 | links["User1:4<->User4:3"] = Link(interfaces["User1:4"], | ||
| 508 | interfaces["User4:3"]) | ||
| 509 |