M8-R11: make business timezone deterministic
This commit is contained in:
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from decimal import Decimal
|
||||
from unittest.mock import patch
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
@@ -139,7 +140,9 @@ def test_meter_cost_summary_empty_and_recompute_csrf_window_validation(meter_cos
|
||||
).status_code == 422
|
||||
|
||||
|
||||
def test_meter_cost_summary_returns_five_fixed_components_and_totals(meter_cost_client) -> None:
|
||||
def test_meter_cost_summary_returns_five_fixed_components_and_totals(
|
||||
meter_cost_client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
client, engine = meter_cost_client
|
||||
now = datetime.now(UTC)
|
||||
values = {
|
||||
@@ -166,8 +169,10 @@ def test_meter_cost_summary_returns_five_fixed_components_and_totals(meter_cost_
|
||||
db.add_all((heating, water))
|
||||
db.commit()
|
||||
_login(client)
|
||||
with patch("app.api.routes.api.meter_costs.local_now", return_value=datetime(2026, 6, 25, 2, tzinfo=UTC)):
|
||||
response = client.get("/api/energy/meter-costs/summary?scope=thermal&start=2026-06-23T00:00:00Z&end=2026-06-24T00:00:00Z")
|
||||
monkeypatch.setattr("app.services.timezone.local_tz", lambda: ZoneInfo("Europe/Amsterdam"))
|
||||
response = client.get(
|
||||
"/api/energy/meter-costs/summary?scope=thermal&start=2026-06-23T00:00:00Z&end=2026-06-24T00:00:00Z"
|
||||
)
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert body["heating"] == "1.000000000" and body["hot_water_heating"] == "0.8"
|
||||
|
||||
Reference in New Issue
Block a user