Commit a677a64
authored
Merge pull request #967 from cderici/optimize-fix-destroy-units-issue950
#967
#### Description
This change does two things:
1. Fixes the #950 as @addyess suggested.
2. Optimizes the `model.destroy_units` where currently we're calling the API (`ApplicationFacade.DestroyUnits`) for each unit to be destroyed. This changes it so that the API is called only once with the list of the units.
Fixes #950
#### QA Steps
Added an integration test for the first case:
```
tox -e integration -- tests/integration/test_unit.py::test_destroy_unit
```
For the `model.destroy_units()` we already have a test:
```
tox -e integration -- tests/integration/test_model.py::test_destroy_units
```
Additionally, we also have a bunch of tests that use the `model.destroy_units()`, so they should be passing as well in the CI.
All CI tests need to pass.
#### Notes & Discussion
Normally it should be the case where the `model.destroy_units()` would use the `Unit.destroy()` on the Unit object. However, doing that for multiple units would be either inefficient (call `u.destroy()` for each unit -- thereby having the same inefficiency that we currently have), or a bit awkward since a unit would be requesting removal for other units. That's why we keep the `model.destroy_units`, as well as the `unit.destroy()` essentially doing the same thing.3 files changed
Lines changed: 47 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2157 | 2157 | | |
2158 | 2158 | | |
2159 | 2159 | | |
2160 | | - | |
2161 | | - | |
2162 | | - | |
2163 | | - | |
2164 | | - | |
2165 | | - | |
2166 | | - | |
2167 | | - | |
2168 | | - | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
2174 | | - | |
2175 | | - | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
2179 | 2166 | | |
2180 | 2167 | | |
2181 | 2168 | | |
2182 | 2169 | | |
2183 | 2170 | | |
2184 | | - | |
2185 | | - | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
2186 | 2189 | | |
2187 | 2190 | | |
2188 | 2191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
0 commit comments