Repository navigation
Energy-Charts: Börsenpreisobergrenze ergänzt - #4284
Conversation
Reviewer's GuideSchema and migrationsBump the datastore version and migrate existing Energy-Charts provider configurations to include the optional
Data structuresAdd the optional
ImplementationApply the configured price cap to the raw Energy-Charts price before adding the surcharge and calculating tax.
TestsTest datastore migration behavior for Energy-Charts configurations with and without an existing price cap, as well as other providers.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/helpermodules/update_config.py" line_range="4208" />
<code_context>
+ return None
+
+ self._loop_all_received_topics(upgrade)
+ self._append_datastore_version(156)
</code_context>
<issue_to_address>
**Failed migration is marked complete**
When the retained provider payload has not arrived, decoding fails, or an Energy-Charts payload has a missing or null configuration, `_loop_all_received_topics` leaves the provider unmigrated, but `upgrade_datastore_156` still calls `_append_datastore_version(156)`, so later startups skip the migration and the configuration stays incomplete.
Only append datastore version 156 after confirming the provider migration completed successfully.
Also at `packages/helpermodules/update_config.py:4201`, `packages/helpermodules/update_config.py:4207`.
</issue_to_address>
### Comment 2
<location path="packages/helpermodules/update_config_test.py" line_range="666-667" />
<code_context>
+ assert json.loads(uc.all_received_topics[topic]) == {
+ "type": provider_type, "configuration": expected_configuration
+ }
+ updated_topics = [call.args[0] for call in mock_pub.pub.call_args_list]
+ assert (topic in updated_topics) is updated
+ assert uc.all_received_topics["openWB/system/datastore_version"] == [155, 156]
</code_context>
<issue_to_address>
**Wrong migration payload goes unnoticed**
When `Pub.pub` receives a payload different from the migrated provider configuration, `test_upgrade_datastore_156_adds_energycharts_price_cap` extracts only `call.args[0]` at line 666 and checks only the topic at line 667, so it passes when `Pub.pub` publishes an incorrect payload for that topic. The migration can therefore publish the wrong provider configuration without this test detecting it.
Assert that the publication for the provider topic carries the expected migrated configuration.
</issue_to_address>| return None | ||
|
|
||
| self._loop_all_received_topics(upgrade) | ||
| self._append_datastore_version(156) |
There was a problem hiding this comment.
🟡 Medium · Failed migration is marked complete
When the retained provider payload has not arrived, decoding fails, or an Energy-Charts payload has a missing or null configuration, _loop_all_received_topics leaves the provider unmigrated, but upgrade_datastore_156 still calls _append_datastore_version(156), so later startups skip the migration and the configuration stays incomplete.
Only append datastore version 156 after confirming the provider migration completed successfully.
Also at packages/helpermodules/update_config.py:4201, packages/helpermodules/update_config.py:4207.
Prompt for AI agents
In `packages/helpermodules/update_config.py` at line 4208:
**Failed migration is marked complete**
When the retained provider payload has not arrived, decoding fails, or an Energy-Charts payload has a missing or null configuration, `_loop_all_received_topics` leaves the provider unmigrated, but `upgrade_datastore_156` still calls `_append_datastore_version(156)`, so later startups skip the migration and the configuration stays incomplete.
Only append datastore version 156 after confirming the provider migration completed successfully.
Also at `packages/helpermodules/update_config.py:4201`, `packages/helpermodules/update_config.py:4207`.| updated_topics = [call.args[0] for call in mock_pub.pub.call_args_list] | ||
| assert (topic in updated_topics) is updated |
There was a problem hiding this comment.
🟡 Medium · Wrong migration payload goes unnoticed
When Pub.pub receives a payload different from the migrated provider configuration, test_upgrade_datastore_156_adds_energycharts_price_cap extracts only call.args[0] at line 666 and checks only the topic at line 667, so it passes when Pub.pub publishes an incorrect payload for that topic. The migration can therefore publish the wrong provider configuration without this test detecting it.
Assert that the publication for the provider topic carries the expected migrated configuration.
Prompt for AI agents
In `packages/helpermodules/update_config_test.py` at lines 666-667:
**Wrong migration payload goes unnoticed**
When `Pub.pub` receives a payload different from the migrated provider configuration, `test_upgrade_datastore_156_adds_energycharts_price_cap` extracts only `call.args[0]` at line 666 and checks only the topic at line 667, so it passes when `Pub.pub` publishes an incorrect payload for that topic. The migration can therefore publish the wrong provider configuration without this test detecting it.
Assert that the publication for the provider topic carries the expected migrated configuration.upgrade_datastore_156 is now the Energy-Charts price cap (openWB#4284); the weekdays repair moves to 157.
upgrade_datastore_156 is now the Energy-Charts price cap (openWB#4284); data_tariff_split moves to 157.
Ticket #66010050
UI openWB/openwb-ui-settings#1165
Summary by Sourcery
Add an optional exchange-price cap for Energy-Charts tariffs and migrate existing configurations to the new setting.
New Features:
Enhancements:
Tests:
Chores: