| Conditions | 1 |
| Total Lines | 60 |
| Code Lines | 51 |
| 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.""" |
||
| 111 | @staticmethod |
||
| 112 | def generate_topology(): |
||
| 113 | """Generates a predetermined topology""" |
||
| 114 | switches = {} |
||
| 115 | interfaces = {} |
||
| 116 | links = {} |
||
| 117 | |||
| 118 | TestResults.create_switch("User1", switches) |
||
| 119 | TestResults.add_interfaces(3, switches["User1"], interfaces) |
||
| 120 | |||
| 121 | TestResults.create_switch("S2", switches) |
||
| 122 | TestResults.add_interfaces(2, switches["S2"], interfaces) |
||
| 123 | |||
| 124 | TestResults.create_switch("User2", switches) |
||
| 125 | TestResults.add_interfaces(3, switches["User2"], interfaces) |
||
| 126 | |||
| 127 | TestResults.create_switch("S4", switches) |
||
| 128 | TestResults.add_interfaces(4, switches["S4"], interfaces) |
||
| 129 | |||
| 130 | TestResults.create_switch("S5", switches) |
||
| 131 | TestResults.add_interfaces(2, switches["S5"], interfaces) |
||
| 132 | |||
| 133 | TestResults.create_link("User1:1", "S2:1", interfaces, links) |
||
| 134 | TestResults.create_link("User1:2", "S5:1", interfaces, links) |
||
| 135 | TestResults.create_link("User1:3", "S4:1", interfaces, links) |
||
| 136 | TestResults.create_link("S2:2", "User2:1", interfaces, links) |
||
| 137 | TestResults.create_link("User2:2", "S4:2", interfaces, links) |
||
| 138 | TestResults.create_link("S5:2", "S4:3", interfaces, links) |
||
| 139 | TestResults.create_link("User2:3", "S4:4", interfaces, links) |
||
| 140 | |||
| 141 | TestResults.add_metadata_to_link( |
||
| 142 | "User1:1", "S2:1", { |
||
| 143 | "reliability": 3, "ownership": "B", "delay": 30, |
||
| 144 | "bandwidth": 20}, links) |
||
| 145 | TestResults.add_metadata_to_link( |
||
| 146 | "User1:2", "S5:1", { |
||
| 147 | "reliability": 1, "ownership": "A", "delay": 5, |
||
| 148 | "bandwidth": 50}, links) |
||
| 149 | TestResults.add_metadata_to_link( |
||
| 150 | "User1:3", "S4:1", { |
||
| 151 | "reliability": 3, "ownership": "A", "delay": 60, |
||
| 152 | "bandwidth": 10}, links) |
||
| 153 | TestResults.add_metadata_to_link( |
||
| 154 | "S2:2", "User2:1", { |
||
| 155 | "reliability": 3, "ownership": "B", "delay": 30, |
||
| 156 | "bandwidth": 20}, links) |
||
| 157 | TestResults.add_metadata_to_link( |
||
| 158 | "User2:2", "S4:2", { |
||
| 159 | "reliability": 3, "ownership": "B", "delay": 30, |
||
| 160 | "bandwidth": 10}, links) |
||
| 161 | TestResults.add_metadata_to_link( |
||
| 162 | "S5:2", "S4:3", { |
||
| 163 | "reliability": 1, "ownership": "A", "delay": 10, |
||
| 164 | "bandwidth": 50}, links) |
||
| 165 | TestResults.add_metadata_to_link( |
||
| 166 | "User2:3", "S4:4", { |
||
| 167 | "reliability": 3, "ownership": "A", "delay": 29, |
||
| 168 | "bandwidth": 20}, links) |
||
| 169 | |||
| 170 | return (switches, links) |
||
| 171 |