Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"type": "sense",
"sortOrder": 0,
"created": 1343971266301,
"parent": "parent-0000-0000-0000-000000000001",
"parent": "hub-0000-0000-0000-000000000001",
"props": {
"online": true,
"model": "SENSE",
Expand Down
20 changes: 20 additions & 0 deletions tests/module/test_session_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import AsyncMock, MagicMock

import pytest
from apyhiveapi import Hive
from apyhiveapi.helper.hive_exceptions import (
HiveUnknownConfiguration,
)
Expand Down Expand Up @@ -169,3 +170,22 @@ async def test_heating_group_product_is_not_skipped(self):
}
result = await s.create_devices()
assert len(result["climate"]) == 1


async def test_file_fixture_has_no_dangling_parents(caplog):
"""Every product parent in the bundled fixture resolves to a device.

Regression test: the sense product once pointed at a parent ID that no
device had, so add_list logged a KeyError for each sense entity and the
Glass/Smoke/Dog Bark binary sensors were silently dropped.
"""
async with Hive(username="use@file.com", password="x") as hive:
device_list = await hive.start_session({})

assert not [r for r in caplog.records if r.levelname == "ERROR"]
sense_names = {
d.ha_name
for d in device_list["binary_sensor"]
if d.device_id.startswith("hub-")
}
assert {"Glass Detection", "Smoke Detection", "Dog Bark Detection"} <= sense_names
Loading