Repository navigation
test(core): cover reduced consumption forecast horizon and empty forecast - #477
Conversation
…cast Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The reviewer examined the full diff and found no objective defects, with the two new regression tests correctly following established patterns and leaving no outstanding issues to address.
No open issues 🎉
What changed in this PR
This PR adds two regression tests to tests/batcontrol/test_core.py covering the consumption-forecast horizon handling in core._run_once. It locks in the behavior from PR #476: a consumption forecast shorter than the price/production horizon shortens the control horizon instead of raising, while a completely empty forecast is still treated as a forecast error that falls back via handle_forecast_error. The tests reuse the existing _make_batcontrol_for_grid_charge_target helper to stub the inverter, tariff, solar, consumption, and logic factories.
Changes:
- Add
test_run_reduces_horizon_to_short_consumption_forecast: asserts a 3-slot consumption forecast (vs. 10 price/production slots) shortens the horizon to 3 and does not error. - Add
test_run_treats_empty_consumption_forecast_as_error: asserts an empty consumption forecast triggershandle_forecast_errorand skips the logic calculation.
| File | Description |
|---|---|
| tests/batcontrol/test_core.py | Adds two regression tests covering reduced consumption-forecast horizon and empty-forecast error handling in core._run_once. |
Note (process, not a code defect): as the PR description states, the horizon test depends on the #476 fix, which is present in the reviewed checkout. If this PR were merged ahead of #476, that test would fail — the author already calls out merging #476 first.
Review effort: Balanced
Change
Adds regression tests in
tests/batcontrol/test_core.py:test_run_reduces_horizon_to_short_consumption_forecast: prices/production have 10 slots, consumption only 3. The run must not raise and the logic must get arrays of length 3.test_run_treats_empty_consumption_forecast_as_error: an empty consumption forecast still ends inhandle_forecast_error.Note
The horizon test needs the fix from #476 and fails on
mainwithout it (Not enough consumption forecast data available, requested 9, got 3). Merge #476 first. The same commit is also part of #476.🤖 Generated with Claude Code