From da05fd2f09bc7847b09088c303315787f21aa6e9 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 25 Jun 2026 18:33:19 +0200 Subject: [PATCH] FUE-T03: correct meters POST docstring (no recomputed_periods field) and inaccurate test comments --- app/api/routes/api/meters.py | 7 ++++--- frontend/src/api/schema.d.ts | 7 ++++--- openapi/openapi.json | 2 +- openapi/openapi.yaml | 8 +++++--- tests/test_api_meters.py | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/api/routes/api/meters.py b/app/api/routes/api/meters.py index b92e1a3..a08d2da 100644 --- a/app/api/routes/api/meters.py +++ b/app/api/routes/api/meters.py @@ -185,9 +185,10 @@ def declare_energy_meter( **Retroactive recompute**: if ``started_at`` is in the past, billing records from that point forward are re-judged via ``recompute_range`` to - reflect the new meter attribution. The response includes the count of - recomputed periods in ``recomputed_periods`` (not part of ``MeterResponse`` - — the recompute is transparent; callers should re-fetch costs if needed). + reflect the new meter attribution. The recompute is transparent — the + response body is the created meter (``MeterResponse``) only and does **not** + include a recompute count; callers should re-fetch costs if they need the + updated totals. """ started_at_utc = _localize_started_at(body.started_at) diff --git a/frontend/src/api/schema.d.ts b/frontend/src/api/schema.d.ts index b45072b..c1f6ac7 100644 --- a/frontend/src/api/schema.d.ts +++ b/frontend/src/api/schema.d.ts @@ -591,9 +591,10 @@ export interface paths { * * **Retroactive recompute**: if ``started_at`` is in the past, billing * records from that point forward are re-judged via ``recompute_range`` to - * reflect the new meter attribution. The response includes the count of - * recomputed periods in ``recomputed_periods`` (not part of ``MeterResponse`` - * — the recompute is transparent; callers should re-fetch costs if needed). + * reflect the new meter attribution. The recompute is transparent — the + * response body is the created meter (``MeterResponse``) only and does **not** + * include a recompute count; callers should re-fetch costs if they need the + * updated totals. */ post: operations["declare_energy_meter_api_energy_meters_post"]; delete?: never; diff --git a/openapi/openapi.json b/openapi/openapi.json index b544fbf..745e52f 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1405,7 +1405,7 @@ "api-energy-meters" ], "summary": "Declare Energy Meter", - "description": "Declare a new meter epoch (swap, home move, or initial declaration).\n\nCloses the current active meter for the given commodity at ``started_at``\nand opens a new active meter. If no active meter exists, the new meter is\nsimply created without closing anything.\n\n**Validation**: ``started_at`` must be **≥** the current active meter's\nown ``started_at`` (no chronological backdate below the active epoch's\nstart). Equal timestamps are allowed (replaces the current meter at the\nsame logical moment). Violation → 422.\n\n**Retroactive recompute**: if ``started_at`` is in the past, billing\nrecords from that point forward are re-judged via ``recompute_range`` to\nreflect the new meter attribution. The response includes the count of\nrecomputed periods in ``recomputed_periods`` (not part of ``MeterResponse``\n— the recompute is transparent; callers should re-fetch costs if needed).", + "description": "Declare a new meter epoch (swap, home move, or initial declaration).\n\nCloses the current active meter for the given commodity at ``started_at``\nand opens a new active meter. If no active meter exists, the new meter is\nsimply created without closing anything.\n\n**Validation**: ``started_at`` must be **≥** the current active meter's\nown ``started_at`` (no chronological backdate below the active epoch's\nstart). Equal timestamps are allowed (replaces the current meter at the\nsame logical moment). Violation → 422.\n\n**Retroactive recompute**: if ``started_at`` is in the past, billing\nrecords from that point forward are re-judged via ``recompute_range`` to\nreflect the new meter attribution. The recompute is transparent — the\nresponse body is the created meter (``MeterResponse``) only and does **not**\ninclude a recompute count; callers should re-fetch costs if they need the\nupdated totals.", "operationId": "declare_energy_meter_api_energy_meters_post", "parameters": [ { diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 27d1976..04b6846 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1125,11 +1125,13 @@ paths: records from that point forward are re-judged via ``recompute_range`` to - reflect the new meter attribution. The response includes the count of + reflect the new meter attribution. The recompute is transparent — the - recomputed periods in ``recomputed_periods`` (not part of ``MeterResponse`` + response body is the created meter (``MeterResponse``) only and does **not** - — the recompute is transparent; callers should re-fetch costs if needed).' + include a recompute count; callers should re-fetch costs if they need the + + updated totals.' operationId: declare_energy_meter_api_energy_meters_post parameters: - name: X-CSRF-Token diff --git a/tests/test_api_meters.py b/tests/test_api_meters.py index 07a144e..618420d 100644 --- a/tests/test_api_meters.py +++ b/tests/test_api_meters.py @@ -543,7 +543,7 @@ def test_patch_meter_no_recompute_when_started_at_not_changed(meters_client): # --------------------------------------------------------------------------- -# Timeline continuity (integration: no recompute mock) +# Timeline continuity (recompute mocked to avoid slow computation over empty quarters) # --------------------------------------------------------------------------- @@ -615,7 +615,7 @@ def test_declare_meter_invalid_reason_returns_422(meters_client): # --------------------------------------------------------------------------- -# Retroactive recompute: integration (no mock) — window coverage check +# Retroactive recompute & boundary update (recompute mocked) — window coverage check # ---------------------------------------------------------------------------