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.""" |
||
153 | @staticmethod |
||
154 | def generate_topology(): |
||
155 | """Generates a predetermined topology""" |
||
156 | switches = {} |
||
157 | interfaces = {} |
||
158 | links = {} |
||
159 | |||
160 | TestSearchResults.create_switch("User1", switches) |
||
161 | TestSearchResults.add_interfaces(3, switches["User1"], interfaces) |
||
162 | |||
163 | TestSearchResults.create_switch("S2", switches) |
||
164 | TestSearchResults.add_interfaces(2, switches["S2"], interfaces) |
||
165 | |||
166 | TestSearchResults.create_switch("User2", switches) |
||
167 | TestSearchResults.add_interfaces(3, switches["User2"], interfaces) |
||
168 | |||
169 | TestSearchResults.create_switch("S4", switches) |
||
170 | TestSearchResults.add_interfaces(4, switches["S4"], interfaces) |
||
171 | |||
172 | TestSearchResults.create_switch("S5", switches) |
||
173 | TestSearchResults.add_interfaces(2, switches["S5"], interfaces) |
||
174 | |||
175 | TestSearchResults.create_link("User1:1", "S2:1", interfaces, links) |
||
176 | TestSearchResults.create_link("User1:2", "S5:1", interfaces, links) |
||
177 | TestSearchResults.create_link("User1:3", "S4:1", interfaces, links) |
||
178 | TestSearchResults.create_link("S2:2", "User2:1", interfaces, links) |
||
179 | TestSearchResults.create_link("User2:2", "S4:2", interfaces, links) |
||
180 | TestSearchResults.create_link("S5:2", "S4:3", interfaces, links) |
||
181 | TestSearchResults.create_link("User2:3", "S4:4", interfaces, links) |
||
182 | |||
183 | TestSearchResults.add_metadata_to_link( |
||
184 | "User1:1", "S2:1", { |
||
185 | "reliability": 3, "ownership": "B", "delay": 30, |
||
186 | "bandwidth": 20}, links) |
||
187 | TestSearchResults.add_metadata_to_link( |
||
188 | "User1:2", "S5:1", { |
||
189 | "reliability": 1, "ownership": "A", "delay": 5, |
||
190 | "bandwidth": 50}, links) |
||
191 | TestSearchResults.add_metadata_to_link( |
||
192 | "User1:3", "S4:1", { |
||
193 | "reliability": 3, "ownership": "A", "delay": 60, |
||
194 | "bandwidth": 10}, links) |
||
195 | TestSearchResults.add_metadata_to_link( |
||
196 | "S2:2", "User2:1", { |
||
197 | "reliability": 3, "ownership": "B", "delay": 30, |
||
198 | "bandwidth": 20}, links) |
||
199 | TestSearchResults.add_metadata_to_link( |
||
200 | "User2:2", "S4:2", { |
||
201 | "reliability": 3, "ownership": "B", "delay": 30, |
||
202 | "bandwidth": 10}, links) |
||
203 | TestSearchResults.add_metadata_to_link( |
||
204 | "S5:2", "S4:3", { |
||
205 | "reliability": 1, "ownership": "A", "delay": 10, |
||
206 | "bandwidth": 50}, links) |
||
207 | TestSearchResults.add_metadata_to_link( |
||
208 | "User2:3", "S4:4", { |
||
209 | "reliability": 3, "ownership": "A", "delay": 29, |
||
210 | "bandwidth": 20}, links) |
||
211 | |||
212 | return (switches, links) |
||
213 |