Skip to content

test(core): cover reduced consumption forecast horizon and empty forecast - #477

Merged
MaStr merged 1 commit into
mainfrom
test/consumption-forecast-horizon
Oct 28, 2026
Merged

MaStr merged 1 commit into
mainfrom
test/consumption-forecast-horizon

Conversation

@MaStr

@MaStr MaStr commented Oct 28, 2026

Copy link
Copy Markdown
Owner

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 in handle_forecast_error.

Note

The horizon test needs the fix from #476 and fails on main without 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

…cast

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 19:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 triggers handle_forecast_error and 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

@MaStr
MaStr merged commit 9a5563f into main Oct 28, 2026
13 checks passed
@MaStr
MaStr deleted the test/consumption-forecast-horizon branch October 28, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants