From f4cea3874b49c466e34b989ed25e6f23d10f6b7d Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Fri, 17 Jul 2026 18:49:26 +0200 Subject: [PATCH] test(energy-cost): pin local_now in future-window summarize test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_future_window_counts_0_days relied on the real wall-clock date and assumed 7/1→8/1 2026 was entirely in the future; once that range started elapsing the window counted fixed-fee days and the assertion failed. Pin local_now to June 25 2026 (as the sibling window tests already do) so the case stays deterministic. --- tests/test_energy_cost.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_energy_cost.py b/tests/test_energy_cost.py index 9f75d65..6da29e6 100644 --- a/tests/test_energy_cost.py +++ b/tests/test_energy_cost.py @@ -1263,6 +1263,9 @@ class TestSummarizePrincipleC: def test_future_window_counts_0_days(self, energy_db: Session) -> None: """A fully future window (all local dates > today) counts 0 days. + Pins ``local_now`` to June 25 2026 noon AMS so the 7/1→8/1 window is + genuinely in the future regardless of the actual wall-clock date + (mirrors the sibling window tests, which all pin ``local_now``). Matches table row: 7/1→8/1 (all future) → 0 days. """ eff_utc = _ams_midnight(2026, 6, 1) @@ -1270,7 +1273,9 @@ class TestSummarizePrincipleC: start = _ams_midnight(2026, 7, 1) end = _ams_midnight(2026, 8, 1) - result = self._run_summarize_ams(energy_db, start, end) + # Pin local_now to June 25 2026 noon AMS so 7/1→8/1 stays fully future. + pinned_now = datetime(2026, 6, 25, 12, 0, 0, tzinfo=_ams()) + result = self._run_summarize_ams(energy_db, start, end, pinned_now=pinned_now) assert result["fixed_costs"] == 0.0, ( f"All-future window must count 0 days; got fixed_costs={result['fixed_costs']}"