add reset functionality for attribute and tests #761
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #760
Description copied from issue:
For attributes, for which a
__get__
via element.attribute (e.g. tz.lighting_power) has been performed before and thus are already calculated, the status will be
STATUS_AVAILABLE. Those attributes won't be recalculated again if the
get` method is called again. This behaviour is on purpose and totally fine, but in some cases (e.g. enrichment) we want to reset those attributes, to make sure that the enrichment works properly.Solution
This implements a reset() functionality useable through
element.reset('lighting_power')
In
test_attribute_reset_with_function_change()
we identified a behavior where functions computing results based on a base value x require manual intervention when x changes:Current Status:
While not ideal, this behavior is manageable as long as we properly use the reset functionality.
Decision:
Following the principle "Perfect is the enemy of the good. Half broken is better than completely broken," we'll keep this behavior for now. The current solution, though requiring manual intervention, is functional and understood. I also added a commit to this in the reset() function.