✨ feat: electricity contract endpoints #61

Merged
mat merged 1 commit from electricity-contract into main 2026-09-06 17:39:12 +00:00
Owner

What

Resolves the /api/electricitycontract/{id} TODO from ROADMAP.md §1 and ships the two read-only client methods from §3.

Verified live (2026-09-06, read-only)

GET /api/electricitycontract/{site_id} — no query parameter, path param is the numeric site id, response is a JSON array:

  • GET /api/electricitycontract/3349 → 200 [] (probe site has no contract)

The earlier TODO ("required query parameter not pinned down") was a false lead: the collection path /api/electricitycontract?siteId= simply has no handler (404); the per-site contract lives at the {id} path segment.

Caveat (documented in misc-endpoints.md): the server does not 404 on an unknown id — on the probe account both the siteUid and a bogus numeric id also return 200 [] — so "site id" semantics rest on the SPA bundle (which builds the URL from the numeric site id), not on server-side validation. The non-empty array shape is unverified: the probe site carries no contract. PUT (write path) is not verified live.

Changes

  • comwatt_client/_electricity_contracts.py — new ElectricityContractsMixin:
    • get_electricity_contract(site_id)
    • get_electricity_contract_providers()
  • comwatt_client/client.py — wire the mixin into ComwattClient.
  • tests/test_electricity_contracts.py — responses with hand-written payloads (no captured live data, per ROADMAP §5).
  • docs/energy.comwatt.com/misc-endpoints.md — resolve the TODO; document the caveats.
  • ROADMAP.md — tick the §1 and §3 boxes.

Tests

  • pytest: 139 passed (133 baseline + 6 new), 0 failures.
  • mypy: clean.
## What Resolves the `/api/electricitycontract/{id}` TODO from `ROADMAP.md` §1 and ships the two read-only client methods from §3. ## Verified live (2026-09-06, read-only) `GET /api/electricitycontract/{site_id}` — no query parameter, path param is the **numeric site id**, response is a **JSON array**: - `GET /api/electricitycontract/3349` → `200 []` (probe site has no contract) The earlier TODO ("required query parameter not pinned down") was a false lead: the collection path `/api/electricitycontract?siteId=` simply has no handler (404); the per-site contract lives at the `{id}` path segment. **Caveat (documented in `misc-endpoints.md`):** the server does not 404 on an unknown id — on the probe account both the `siteUid` and a bogus numeric id also return `200 []` — so "site id" semantics rest on the SPA bundle (which builds the URL from the numeric site id), not on server-side validation. The non-empty array shape is **unverified**: the probe site carries no contract. `PUT` (write path) is not verified live. ## Changes - `comwatt_client/_electricity_contracts.py` — new `ElectricityContractsMixin`: - `get_electricity_contract(site_id)` - `get_electricity_contract_providers()` - `comwatt_client/client.py` — wire the mixin into `ComwattClient`. - `tests/test_electricity_contracts.py` — `responses` with hand-written payloads (no captured live data, per ROADMAP §5). - `docs/energy.comwatt.com/misc-endpoints.md` — resolve the TODO; document the caveats. - `ROADMAP.md` — tick the §1 and §3 boxes. ## Tests - `pytest`: 139 passed (133 baseline + 6 new), 0 failures. - `mypy`: clean.
✨ feat: electricity contract endpoints
All checks were successful
Tests / forgejo-pytest (push) Successful in 42s
Tests / forgejo-pytest (pull_request) Successful in 42s
4744f30554
Resolve the /api/electricitycontract/{id} TODO (misc-endpoints.md):
the path param is the numeric site id, the response is a JSON array
([] when the site has no contract), and no query parameter is involved
— verified live 2026-09-06. The earlier 'required query parameter' note
was a false lead (the collection path simply has no handler).

Add two read-only client methods in a new ElectricityContractsMixin:
- get_electricity_contract(site_id)
- get_electricity_contract_providers()

Tests use responses with hand-written payloads (no captured live data).
Tick the matching ROADMAP §1 and §3 boxes.
mat changed title from WIP: ✨ feat: electricity contract endpoints to ✨ feat: electricity contract endpoints 2026-09-06 17:38:45 +00:00
mat merged commit e41fe7ff06 into main 2026-09-06 17:39:12 +00:00
mat deleted branch electricity-contract 2026-09-06 17:39:12 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mat/python-comwatt-client!61
No description provided.