(self)
| 252 | ) |
| 253 | |
| 254 | def _get_changes(self) -> IdentityChangeset: |
| 255 | previous_instance = self._initial_state |
| 256 | changes = {} # type: ignore[var-annotated] |
| 257 | feature_changes = changes.setdefault("feature_overrides", {}) |
| 258 | previous_feature_overrides = { |
| 259 | fs.featurestate_uuid: fs for fs in previous_instance.feature_overrides |
| 260 | } |
| 261 | current_feature_overrides = { |
| 262 | fs.featurestate_uuid: fs for fs in self.feature_overrides |
| 263 | } |
| 264 | |
| 265 | for uuid_, previous_fs in previous_feature_overrides.items(): |
| 266 | current_matching_fs = current_feature_overrides.get(uuid_) |
| 267 | if current_matching_fs is None: |
| 268 | feature_changes[previous_fs.feature.name] = generate_change_dict( |
| 269 | change_type="-", |
| 270 | identity_id=self.id, |
| 271 | old=previous_fs, |
| 272 | ) |
| 273 | elif ( |
| 274 | current_matching_fs.enabled != previous_fs.enabled |
| 275 | or current_matching_fs.get_value(self.id) |
| 276 | != previous_fs.get_value(self.id) |
| 277 | ): |
| 278 | feature_changes[previous_fs.feature.name] = generate_change_dict( |
| 279 | change_type="~", |
| 280 | identity_id=self.id, |
| 281 | new=current_matching_fs, |
| 282 | old=previous_fs, |
| 283 | ) |
| 284 | |
| 285 | for uuid_, previous_fs in current_feature_overrides.items(): |
| 286 | if uuid_ not in previous_feature_overrides: |
| 287 | feature_changes[previous_fs.feature.name] = generate_change_dict( |
| 288 | change_type="+", |
| 289 | identity_id=self.id, |
| 290 | new=previous_fs, |
| 291 | ) |
| 292 | |
| 293 | return changes # type: ignore[return-value] |
| 294 | |
| 295 | def _reset_initial_state(self): # type: ignore[no-untyped-def] |
| 296 | self._initial_state = copy.deepcopy(self) |
no test coverage detected