| Conditions | 1 |
| Total Lines | 181 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 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 for testing grouped optimizer.""" |
||
| 34 | def test_calling_functions(self): |
||
| 35 | """Test correct order of calling function.""" |
||
| 36 | optimizer = GroupedOptimizer(TESTED_PROCESS, GROUPING_STRATEGY, |
||
| 37 | PSO_ALGORITHM) |
||
| 38 | expected_calls = [mock.call.method_name('0', '__init__'), |
||
| 39 | mock.call.method_name('1', '__init__'), |
||
| 40 | mock.call.method_name('2', '__init__'), |
||
| 41 | mock.call.method_name('3', '__init__'), |
||
| 42 | mock.call.method_name('4', '__init__'), |
||
| 43 | mock.call.method_name('5', '__init__'), |
||
| 44 | mock.call.method_name('6', '__init__'), |
||
| 45 | mock.call.method_name('0', 'get_output_of_stage', 1), |
||
| 46 | mock.call.method_name('1', 'get_output_of_stage', 1), |
||
| 47 | mock.call.method_name('2', 'get_output_of_stage', 1), |
||
| 48 | mock.call.method_name('0', 'get_quality', 1), |
||
| 49 | mock.call.method_name('1', 'get_quality', 1), |
||
| 50 | mock.call.method_name('2', 'get_quality', 1), |
||
| 51 | mock.call.method_name('0', 'is_enough_quality', 1), |
||
| 52 | mock.call.method_name('0', 'could_be_optimized', 1), |
||
| 53 | mock.call.method_name('1', 'is_enough_quality', 1), |
||
| 54 | mock.call.method_name('1', 'could_be_optimized', 1), |
||
| 55 | mock.call.method_name('2', 'is_enough_quality', 1), |
||
| 56 | mock.call.method_name('2', 'could_be_optimized', 1), |
||
| 57 | mock.call.method_name('0', 'get_output_of_stage', 2), |
||
| 58 | mock.call.method_name('1', 'get_output_of_stage', 2), |
||
| 59 | mock.call.method_name('2', 'get_output_of_stage', 2), |
||
| 60 | mock.call.method_name('0', 'get_quality', 2), |
||
| 61 | mock.call.method_name('1', 'get_quality', 2), |
||
| 62 | mock.call.method_name('2', 'get_quality', 2), |
||
| 63 | mock.call.method_name('0', 'is_enough_quality', 2), |
||
| 64 | mock.call.method_name('0', 'could_be_optimized', 2), |
||
| 65 | mock.call.method_name('1', 'is_enough_quality', 2), |
||
| 66 | mock.call.method_name('1', 'could_be_optimized', 2), |
||
| 67 | mock.call.method_name('2', 'is_enough_quality', 2), |
||
| 68 | mock.call.method_name('2', 'could_be_optimized', 2), |
||
| 69 | mock.call.method_name('0', 'get_output_of_stage', 3), |
||
| 70 | mock.call.method_name('1', 'get_output_of_stage', 3), |
||
| 71 | mock.call.method_name('2', 'get_output_of_stage', 3), |
||
| 72 | mock.call.method_name('0', 'get_quality', 3), |
||
| 73 | mock.call.method_name('1', 'get_quality', 3), |
||
| 74 | mock.call.method_name('2', 'get_quality', 3), |
||
| 75 | mock.call.method_name('0', 'is_enough_quality', 3), |
||
| 76 | mock.call.method_name('0', 'could_be_optimized', 3), |
||
| 77 | mock.call.method_name('1', 'is_enough_quality', 3), |
||
| 78 | mock.call.method_name('1', 'could_be_optimized', 3), |
||
| 79 | mock.call.method_name('2', 'is_enough_quality', 3), |
||
| 80 | mock.call.method_name('2', 'could_be_optimized', 3), |
||
| 81 | mock.call.method_name('0', 'get_output_of_stage', 4), |
||
| 82 | mock.call.method_name('1', 'get_output_of_stage', 4), |
||
| 83 | mock.call.method_name('2', 'get_output_of_stage', 4), |
||
| 84 | mock.call.method_name('0', 'get_quality', 4), |
||
| 85 | mock.call.method_name('1', 'get_quality', 4), |
||
| 86 | mock.call.method_name('2', 'get_quality', 4), |
||
| 87 | mock.call.method_name('0', 'is_enough_quality', 4), |
||
| 88 | mock.call.method_name('0', 'could_be_optimized', 4), |
||
| 89 | mock.call.method_name('1', 'is_enough_quality', 4), |
||
| 90 | mock.call.method_name('1', 'could_be_optimized', 4), |
||
| 91 | mock.call.method_name('2', 'is_enough_quality', 4), |
||
| 92 | mock.call.method_name('2', 'could_be_optimized', 4), |
||
| 93 | mock.call.method_name('0', 'get_output_of_stage', 5), |
||
| 94 | mock.call.method_name('1', 'get_output_of_stage', 5), |
||
| 95 | mock.call.method_name('2', 'get_output_of_stage', 5), |
||
| 96 | mock.call.method_name('0', 'get_quality', 5), |
||
| 97 | mock.call.method_name('1', 'get_quality', 5), |
||
| 98 | mock.call.method_name('2', 'get_quality', 5), |
||
| 99 | mock.call.method_name('0', 'is_enough_quality', 5), |
||
| 100 | mock.call.method_name('0', 'could_be_optimized', 5), |
||
| 101 | mock.call.method_name('1', 'is_enough_quality', 5), |
||
| 102 | mock.call.method_name('1', 'could_be_optimized', 5), |
||
| 103 | mock.call.method_name('2', 'is_enough_quality', 5), |
||
| 104 | mock.call.method_name('2', 'could_be_optimized', 5), |
||
| 105 | mock.call.method_name('0', 'get_output_of_stage', 6), |
||
| 106 | mock.call.method_name('1', 'get_output_of_stage', 6), |
||
| 107 | mock.call.method_name('2', 'get_output_of_stage', 6), |
||
| 108 | mock.call.method_name('0', 'get_quality', 6), |
||
| 109 | mock.call.method_name('1', 'get_quality', 6), |
||
| 110 | mock.call.method_name('2', 'get_quality', 6), |
||
| 111 | mock.call.method_name('0', 'is_enough_quality', 6), |
||
| 112 | mock.call.method_name('0', 'could_be_optimized', 6), |
||
| 113 | mock.call.method_name('1', 'is_enough_quality', 6), |
||
| 114 | mock.call.method_name('1', 'could_be_optimized', 6), |
||
| 115 | mock.call.method_name('2', 'is_enough_quality', 6), |
||
| 116 | mock.call.method_name('2', 'could_be_optimized', 6), |
||
| 117 | mock.call.method_name('3', 'get_output_of_stage', 1), |
||
| 118 | mock.call.method_name('4', 'get_output_of_stage', 1), |
||
| 119 | mock.call.method_name('5', 'get_output_of_stage', 1), |
||
| 120 | mock.call.method_name('3', 'get_quality', 1), |
||
| 121 | mock.call.method_name('4', 'get_quality', 1), |
||
| 122 | mock.call.method_name('5', 'get_quality', 1), |
||
| 123 | mock.call.method_name('3', 'is_enough_quality', 1), |
||
| 124 | mock.call.method_name('3', 'could_be_optimized', 1), |
||
| 125 | mock.call.method_name('4', 'is_enough_quality', 1), |
||
| 126 | mock.call.method_name('4', 'could_be_optimized', 1), |
||
| 127 | mock.call.method_name('5', 'is_enough_quality', 1), |
||
| 128 | mock.call.method_name('5', 'could_be_optimized', 1), |
||
| 129 | mock.call.method_name('3', 'get_output_of_stage', 2), |
||
| 130 | mock.call.method_name('4', 'get_output_of_stage', 2), |
||
| 131 | mock.call.method_name('5', 'get_output_of_stage', 2), |
||
| 132 | mock.call.method_name('3', 'get_quality', 2), |
||
| 133 | mock.call.method_name('4', 'get_quality', 2), |
||
| 134 | mock.call.method_name('5', 'get_quality', 2), |
||
| 135 | mock.call.method_name('3', 'is_enough_quality', 2), |
||
| 136 | mock.call.method_name('3', 'could_be_optimized', 2), |
||
| 137 | mock.call.method_name('4', 'is_enough_quality', 2), |
||
| 138 | mock.call.method_name('4', 'could_be_optimized', 2), |
||
| 139 | mock.call.method_name('5', 'is_enough_quality', 2), |
||
| 140 | mock.call.method_name('5', 'could_be_optimized', 2), |
||
| 141 | mock.call.method_name('3', 'get_output_of_stage', 3), |
||
| 142 | mock.call.method_name('4', 'get_output_of_stage', 3), |
||
| 143 | mock.call.method_name('5', 'get_output_of_stage', 3), |
||
| 144 | mock.call.method_name('3', 'get_quality', 3), |
||
| 145 | mock.call.method_name('4', 'get_quality', 3), |
||
| 146 | mock.call.method_name('5', 'get_quality', 3), |
||
| 147 | mock.call.method_name('3', 'is_enough_quality', 3), |
||
| 148 | mock.call.method_name('3', 'could_be_optimized', 3), |
||
| 149 | mock.call.method_name('4', 'is_enough_quality', 3), |
||
| 150 | mock.call.method_name('4', 'could_be_optimized', 3), |
||
| 151 | mock.call.method_name('5', 'is_enough_quality', 3), |
||
| 152 | mock.call.method_name('5', 'could_be_optimized', 3), |
||
| 153 | mock.call.method_name('3', 'get_output_of_stage', 4), |
||
| 154 | mock.call.method_name('4', 'get_output_of_stage', 4), |
||
| 155 | mock.call.method_name('5', 'get_output_of_stage', 4), |
||
| 156 | mock.call.method_name('3', 'get_quality', 4), |
||
| 157 | mock.call.method_name('4', 'get_quality', 4), |
||
| 158 | mock.call.method_name('5', 'get_quality', 4), |
||
| 159 | mock.call.method_name('3', 'is_enough_quality', 4), |
||
| 160 | mock.call.method_name('3', 'could_be_optimized', 4), |
||
| 161 | mock.call.method_name('4', 'is_enough_quality', 4), |
||
| 162 | mock.call.method_name('4', 'could_be_optimized', 4), |
||
| 163 | mock.call.method_name('5', 'is_enough_quality', 4), |
||
| 164 | mock.call.method_name('5', 'could_be_optimized', 4), |
||
| 165 | mock.call.method_name('3', 'get_output_of_stage', 5), |
||
| 166 | mock.call.method_name('4', 'get_output_of_stage', 5), |
||
| 167 | mock.call.method_name('5', 'get_output_of_stage', 5), |
||
| 168 | mock.call.method_name('3', 'get_quality', 5), |
||
| 169 | mock.call.method_name('4', 'get_quality', 5), |
||
| 170 | mock.call.method_name('5', 'get_quality', 5), |
||
| 171 | mock.call.method_name('3', 'is_enough_quality', 5), |
||
| 172 | mock.call.method_name('3', 'could_be_optimized', 5), |
||
| 173 | mock.call.method_name('4', 'is_enough_quality', 5), |
||
| 174 | mock.call.method_name('4', 'could_be_optimized', 5), |
||
| 175 | mock.call.method_name('5', 'is_enough_quality', 5), |
||
| 176 | mock.call.method_name('5', 'could_be_optimized', 5), |
||
| 177 | mock.call.method_name('3', 'get_output_of_stage', 6), |
||
| 178 | mock.call.method_name('4', 'get_output_of_stage', 6), |
||
| 179 | mock.call.method_name('5', 'get_output_of_stage', 6), |
||
| 180 | mock.call.method_name('3', 'get_quality', 6), |
||
| 181 | mock.call.method_name('4', 'get_quality', 6), |
||
| 182 | mock.call.method_name('5', 'get_quality', 6), |
||
| 183 | mock.call.method_name('3', 'is_enough_quality', 6), |
||
| 184 | mock.call.method_name('3', 'could_be_optimized', 6), |
||
| 185 | mock.call.method_name('4', 'is_enough_quality', 6), |
||
| 186 | mock.call.method_name('4', 'could_be_optimized', 6), |
||
| 187 | mock.call.method_name('5', 'is_enough_quality', 6), |
||
| 188 | mock.call.method_name('5', 'could_be_optimized', 6), |
||
| 189 | mock.call.method_name('6', 'get_output_of_stage', 1), |
||
| 190 | mock.call.method_name('6', 'get_quality', 1), |
||
| 191 | mock.call.method_name('6', 'is_enough_quality', 1), |
||
| 192 | mock.call.method_name('6', 'could_be_optimized', 1), |
||
| 193 | mock.call.method_name('6', 'get_output_of_stage', 2), |
||
| 194 | mock.call.method_name('6', 'get_quality', 2), |
||
| 195 | mock.call.method_name('6', 'is_enough_quality', 2), |
||
| 196 | mock.call.method_name('6', 'could_be_optimized', 2), |
||
| 197 | mock.call.method_name('6', 'get_output_of_stage', 3), |
||
| 198 | mock.call.method_name('6', 'get_quality', 3), |
||
| 199 | mock.call.method_name('6', 'is_enough_quality', 3), |
||
| 200 | mock.call.method_name('6', 'could_be_optimized', 3), |
||
| 201 | mock.call.method_name('6', 'get_output_of_stage', 4), |
||
| 202 | mock.call.method_name('6', 'get_quality', 4), |
||
| 203 | mock.call.method_name('6', 'is_enough_quality', 4), |
||
| 204 | mock.call.method_name('6', 'could_be_optimized', 4), |
||
| 205 | mock.call.method_name('6', 'get_output_of_stage', 5), |
||
| 206 | mock.call.method_name('6', 'get_quality', 5), |
||
| 207 | mock.call.method_name('6', 'is_enough_quality', 5), |
||
| 208 | mock.call.method_name('6', 'could_be_optimized', 5), |
||
| 209 | mock.call.method_name('6', 'get_output_of_stage', 6), |
||
| 210 | mock.call.method_name('6', 'get_quality', 6), |
||
| 211 | mock.call.method_name('6', 'is_enough_quality', 6), |
||
| 212 | mock.call.method_name('6', 'could_be_optimized', 6)] |
||
| 213 | optimizer.optimize_process() |
||
| 214 | self.assertListEqual(CALLS_COUNTER.method_calls, expected_calls) |
||
| 215 | |||
| 313 |
This check looks for calls to members that are non-existent. These calls will fail.
The member could have been renamed or removed.