| Conditions | 1 | 
| Total Lines | 175 | 
| Code Lines | 131 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | """Module to test the KytosGraph in graph.py."""  | 
            ||
| 329 | @staticmethod  | 
            ||
| 330 | def generate_topology():  | 
            ||
| 331 | """Generates a predetermined topology"""  | 
            ||
| 332 |         switches = {} | 
            ||
| 333 |         interfaces = {} | 
            ||
| 334 |         links = {} | 
            ||
| 335 | |||
| 336 |         TestSearchResults.create_switch("S1", switches) | 
            ||
| 337 | TestSearchResults.add_interfaces(2, switches["S1"], interfaces)  | 
            ||
| 338 | |||
| 339 |         TestSearchResults.create_switch("S2", switches) | 
            ||
| 340 | TestSearchResults.add_interfaces(2, switches["S2"], interfaces)  | 
            ||
| 341 | |||
| 342 |         TestSearchResults.create_switch("S3", switches) | 
            ||
| 343 | TestSearchResults.add_interfaces(6, switches["S3"], interfaces)  | 
            ||
| 344 | |||
| 345 |         TestSearchResults.create_switch("S4", switches) | 
            ||
| 346 | TestSearchResults.add_interfaces(2, switches["S4"], interfaces)  | 
            ||
| 347 | |||
| 348 |         TestSearchResults.create_switch("S5", switches) | 
            ||
| 349 | TestSearchResults.add_interfaces(6, switches["S5"], interfaces)  | 
            ||
| 350 | |||
| 351 |         TestSearchResults.create_switch("S6", switches) | 
            ||
| 352 | TestSearchResults.add_interfaces(5, switches["S6"], interfaces)  | 
            ||
| 353 | |||
| 354 |         TestSearchResults.create_switch("S7", switches) | 
            ||
| 355 | TestSearchResults.add_interfaces(2, switches["S7"], interfaces)  | 
            ||
| 356 | |||
| 357 |         TestSearchResults.create_switch("S8", switches) | 
            ||
| 358 | TestSearchResults.add_interfaces(8, switches["S8"], interfaces)  | 
            ||
| 359 | |||
| 360 |         TestSearchResults.create_switch("S9", switches) | 
            ||
| 361 | TestSearchResults.add_interfaces(4, switches["S9"], interfaces)  | 
            ||
| 362 | |||
| 363 |         TestSearchResults.create_switch("S10", switches) | 
            ||
| 364 | TestSearchResults.add_interfaces(3, switches["S10"], interfaces)  | 
            ||
| 365 | |||
| 366 |         TestSearchResults.create_switch("S11", switches) | 
            ||
| 367 | TestSearchResults.add_interfaces(3, switches["S11"], interfaces)  | 
            ||
| 368 | |||
| 369 |         TestSearchResults.create_switch("User1", switches) | 
            ||
| 370 | TestSearchResults.add_interfaces(4, switches["User1"], interfaces)  | 
            ||
| 371 | |||
| 372 |         TestSearchResults.create_switch("User2", switches) | 
            ||
| 373 | TestSearchResults.add_interfaces(2, switches["User2"], interfaces)  | 
            ||
| 374 | |||
| 375 |         TestSearchResults.create_switch("User3", switches) | 
            ||
| 376 | TestSearchResults.add_interfaces(2, switches["User3"], interfaces)  | 
            ||
| 377 | |||
| 378 |         TestSearchResults.create_switch("User4", switches) | 
            ||
| 379 | TestSearchResults.add_interfaces(3, switches["User4"], interfaces)  | 
            ||
| 380 | |||
| 381 | links["S1:1<->S2:1"] = Link(interfaces["S1:1"], interfaces["S2:1"])  | 
            ||
| 382 | links["S1:1<->S2:1"].extend_metadata(  | 
            ||
| 383 |             {"reliability": 5, "bandwidth": 100, "delay": 105}) | 
            ||
| 384 | |||
| 385 | links["S1:2<->User1:1"] = Link(interfaces["S1:2"],  | 
            ||
| 386 | interfaces["User1:1"])  | 
            ||
| 387 | links["S1:2<->User1:1"].extend_metadata(  | 
            ||
| 388 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | 
            ||
| 389 | |||
| 390 | links["S2:2<->User4:1"] = Link(interfaces["S2:2"],  | 
            ||
| 391 | interfaces["User4:1"])  | 
            ||
| 392 | links["S2:2<->User4:1"].extend_metadata(  | 
            ||
| 393 |             {"reliability": 5, "bandwidth": 100, "delay": 10}) | 
            ||
| 394 | |||
| 395 | links["S3:1<->S5:1"] = Link(interfaces["S3:1"], interfaces["S5:1"])  | 
            ||
| 396 | links["S3:1<->S5:1"].extend_metadata(  | 
            ||
| 397 |             {"reliability": 5, "bandwidth": 10, "delay": 112}) | 
            ||
| 398 | |||
| 399 | links["S3:2<->S7:1"] = Link(interfaces["S3:2"], interfaces["S7:1"])  | 
            ||
| 400 | links["S3:2<->S7:1"].extend_metadata(  | 
            ||
| 401 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | 
            ||
| 402 | |||
| 403 | links["S3:3<->S8:1"] = Link(interfaces["S3:3"], interfaces["S8:1"])  | 
            ||
| 404 | links["S3:3<->S8:1"].extend_metadata(  | 
            ||
| 405 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | 
            ||
| 406 | |||
| 407 | links["S3:4<->S11:1"] = Link(interfaces["S3:4"], interfaces["S11:1"])  | 
            ||
| 408 | links["S3:4<->S11:1"].extend_metadata(  | 
            ||
| 409 |             {"reliability": 3, "bandwidth": 100, "delay": 6}) | 
            ||
| 410 | |||
| 411 | links["S3:5<->User3:1"] = Link(interfaces["S3:5"],  | 
            ||
| 412 | interfaces["User3:1"])  | 
            ||
| 413 | links["S3:5<->User3:1"].extend_metadata(  | 
            ||
| 414 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | 
            ||
| 415 | |||
| 416 | links["S3:6<->User4:2"] = Link(interfaces["S3:6"],  | 
            ||
| 417 | interfaces["User4:2"])  | 
            ||
| 418 | links["S3:6<->User4:2"].extend_metadata(  | 
            ||
| 419 |             {"reliability": 5, "bandwidth": 100, "delay": 10}) | 
            ||
| 420 | |||
| 421 | links["S4:1<->S5:2"] = Link(interfaces["S4:1"], interfaces["S5:2"])  | 
            ||
| 422 | links["S4:1<->S5:2"].extend_metadata(  | 
            ||
| 423 |             {"reliability": 1, "bandwidth": 100, "delay": 30, | 
            ||
| 424 | "ownership": "A"})  | 
            ||
| 425 | |||
| 426 | links["S4:2<->User1:2"] = Link(interfaces["S4:2"],  | 
            ||
| 427 | interfaces["User1:2"])  | 
            ||
| 428 | links["S4:2<->User1:2"].extend_metadata(  | 
            ||
| 429 |             {"reliability": 3, "bandwidth": 100, "delay": 110, | 
            ||
| 430 | "ownership": "A"})  | 
            ||
| 431 | |||
| 432 | links["S5:3<->S6:1"] = Link(interfaces["S5:3"], interfaces["S6:1"])  | 
            ||
| 433 | links["S5:3<->S6:1"].extend_metadata(  | 
            ||
| 434 |             {"reliability": 1, "bandwidth": 100, "delay": 40}) | 
            ||
| 435 | |||
| 436 | links["S5:4<->S6:2"] = Link(interfaces["S5:4"], interfaces["S6:2"])  | 
            ||
| 437 | links["S5:4<->S6:2"].extend_metadata(  | 
            ||
| 438 |             {"reliability": 3, "bandwidth": 100, "delay": 40, | 
            ||
| 439 | "ownership": "A"})  | 
            ||
| 440 | |||
| 441 | links["S5:5<->S8:2"] = Link(interfaces["S5:5"], interfaces["S8:2"])  | 
            ||
| 442 | links["S5:5<->S8:2"].extend_metadata(  | 
            ||
| 443 |             {"reliability": 5, "bandwidth": 100, "delay": 112}) | 
            ||
| 444 | |||
| 445 | links["S5:6<->User1:3"] = Link(interfaces["S5:6"],  | 
            ||
| 446 | interfaces["User1:3"])  | 
            ||
| 447 | links["S5:6<->User1:3"].extend_metadata(  | 
            ||
| 448 |             {"reliability": 3, "bandwidth": 100, "delay": 60}) | 
            ||
| 449 | |||
| 450 | links["S6:3<->S9:1"] = Link(interfaces["S6:3"], interfaces["S9:1"])  | 
            ||
| 451 | links["S6:3<->S9:1"].extend_metadata(  | 
            ||
| 452 |             {"reliability": 3, "bandwidth": 100, "delay": 60}) | 
            ||
| 453 | |||
| 454 | links["S6:4<->S9:2"] = Link(interfaces["S6:4"], interfaces["S9:2"])  | 
            ||
| 455 | links["S6:4<->S9:2"].extend_metadata(  | 
            ||
| 456 |             {"reliability": 5, "bandwidth": 100, "delay": 62}) | 
            ||
| 457 | |||
| 458 | links["S6:5<->S10:1"] = Link(interfaces["S6:5"], interfaces["S10:1"])  | 
            ||
| 459 | links["S6:5<->S10:1"].extend_metadata(  | 
            ||
| 460 |             {"bandwidth": 100, "delay": 108, "ownership": "A"}) | 
            ||
| 461 | |||
| 462 | links["S7:2<->S8:3"] = Link(interfaces["S7:2"], interfaces["S8:3"])  | 
            ||
| 463 | links["S7:2<->S8:3"].extend_metadata(  | 
            ||
| 464 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | 
            ||
| 465 | |||
| 466 | links["S8:4<->S9:3"] = Link(interfaces["S8:4"], interfaces["S9:3"])  | 
            ||
| 467 | links["S8:4<->S9:3"].extend_metadata(  | 
            ||
| 468 |             {"reliability": 3, "bandwidth": 100, "delay": 32}) | 
            ||
| 469 | |||
| 470 | links["S8:5<->S9:4"] = Link(interfaces["S8:5"], interfaces["S9:4"])  | 
            ||
| 471 | links["S8:5<->S9:4"].extend_metadata(  | 
            ||
| 472 |             {"reliability": 3, "bandwidth": 100, "delay": 110}) | 
            ||
| 473 | |||
| 474 | links["S8:6<->S10:2"] = Link(interfaces["S8:6"], interfaces["S10:2"])  | 
            ||
| 475 | links["S8:6<->S10:2"].extend_metadata(  | 
            ||
| 476 |             {"reliability": 5, "bandwidth": 100, "ownership": "A"}) | 
            ||
| 477 | |||
| 478 | links["S8:7<->S11:2"] = Link(interfaces["S8:7"], interfaces["S11:2"])  | 
            ||
| 479 | links["S8:7<->S11:2"].extend_metadata(  | 
            ||
| 480 |             {"reliability": 3, "bandwidth": 100, "delay": 7}) | 
            ||
| 481 | |||
| 482 | links["S8:8<->User3:2"] = Link(interfaces["S8:8"],  | 
            ||
| 483 | interfaces["User3:2"])  | 
            ||
| 484 | links["S8:8<->User3:2"].extend_metadata(  | 
            ||
| 485 |             {"reliability": 5, "bandwidth": 100, "delay": 1}) | 
            ||
| 486 | |||
| 487 | links["S10:3<->User2:1"] = Link(interfaces["S10:3"],  | 
            ||
| 488 | interfaces["User2:1"])  | 
            ||
| 489 | links["S10:3<->User2:1"].extend_metadata(  | 
            ||
| 490 |             {"reliability": 3, "bandwidth": 100, "delay": 10, | 
            ||
| 491 | "ownership": "A"})  | 
            ||
| 492 | |||
| 493 | links["S11:3<->User2:2"] = Link(interfaces["S11:3"],  | 
            ||
| 494 | interfaces["User2:2"])  | 
            ||
| 495 | links["S11:3<->User2:2"].extend_metadata(  | 
            ||
| 496 |             {"reliability": 3, "bandwidth": 100, "delay": 6}) | 
            ||
| 497 | |||
| 498 | links["User1:4<->User4:3"] = Link(interfaces["User1:4"],  | 
            ||
| 499 | interfaces["User4:3"])  | 
            ||
| 500 | links["User1:4<->User4:3"].extend_metadata(  | 
            ||
| 501 |             {"reliability": 5, "bandwidth": 10, "delay": 105}) | 
            ||
| 502 | |||
| 503 | return (switches, links)  | 
            ||
| 504 |