[client] _request: accept any 2xx as success (201/204 currently raise) #180
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
_request(_core.py:96-97) treats only HTTP 200 as success:Every other status goes to the error path, so a 201/204 from a write endpoint raises
ComwattAPIErrordespite success. This matters now that the write surface exists (set_device_mode,set_alert_config,create_/update_typical_day,update_planning,set_thermal_control), andset_thermal_control's own docstring admits its success path is unverified (_thermal_control.py:60-61) — a 204 answer would currently be reported as an error.Fix:
200 <= status < 300in_request(keep the 401 re-auth retry path unchanged);.json()the response (e.g.switch_capacity,_capacities.py:25): a 204 has an empty body, so they must tolerate it (e.g. return{}) rather than trading a bogusComwattAPIErrorfor aJSONDecodeError;Done when: mocked 201/204 responses return instead of raising, write callers handle empty bodies, tests cover both.