Skip to content

Commit f8ed0f4

Browse files
agnersclaude
andauthored
Fix nullable fields in Supervisor info model (#287)
* Add test for supervisor info with version_latest None Covers the case where version info failed to fetch and the Supervisor API returns null for version_latest. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add test for supervisor info optional fields being None Covers version_latest (version fetch failed) and arch (io.hass.arch label missing) both returning null from the Supervisor API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Drop expected --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 595dc8e commit f8ed0f4

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

aiohasupervisor/models/supervisor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class SupervisorInfo(ResponseData):
2626
"""SupervisorInfo model."""
2727

2828
version: str
29-
version_latest: str
29+
version_latest: str | None
3030
update_available: bool
3131
channel: UpdateChannel
32-
arch: str
32+
arch: str | None
3333
supported: bool
3434
healthy: bool
3535
ip_address: IPv4Address

tests/test_supervisor.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ async def test_supervisor_info(
4747
assert info.detect_blocking_io is False
4848

4949

50+
@pytest.mark.parametrize("field", ["version_latest", "arch"])
51+
async def test_supervisor_info_optional_fields_none(
52+
responses: aioresponses,
53+
supervisor_client: SupervisorClient,
54+
field: str,
55+
) -> None:
56+
"""Test supervisor info API when optional fields are None."""
57+
import json
58+
59+
fixture = json.loads(load_fixture("supervisor_info.json"))
60+
fixture["data"][field] = None
61+
responses.get(
62+
f"{SUPERVISOR_URL}/supervisor/info",
63+
status=200,
64+
payload=fixture,
65+
)
66+
info = await supervisor_client.supervisor.info()
67+
assert getattr(info, field) is None
68+
69+
5070
async def test_supervisor_stats(
5171
responses: aioresponses, supervisor_client: SupervisorClient
5272
) -> None:

0 commit comments

Comments
 (0)