This commit is contained in:
starkillerOG
2025-03-11 20:28:59 +01:00
parent c7e3dfc0ca
commit 1a4577d1d1
2 changed files with 30 additions and 0 deletions

View File

@@ -143,6 +143,10 @@ def reolink_connect_class() -> Generator[MagicMock]:
0: {"chnID": 0, "aitype": 34615}, 0: {"chnID": 0, "aitype": 34615},
"Host": {"pushAlarm": 7}, "Host": {"pushAlarm": 7},
} }
host_mock.baichuan.smart_location_list.return_value = [0]
host_mock.baichuan.smart_ai_type_list.return_value = ["people"]
host_mock.baichuan.smart_ai_index.return_value = 1
host_mock.baichuan.smart_ai_name.return_value = "zone1"
yield host_mock_class yield host_mock_class

View File

@@ -51,6 +51,32 @@ async def test_motion_sensor(
assert hass.states.get(entity_id).state == STATE_ON assert hass.states.get(entity_id).state == STATE_ON
async def test_smart_ai_sensor(
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
freezer: FrozenDateTimeFactory,
config_entry: MockConfigEntry,
reolink_connect: MagicMock,
) -> None:
"""Test smart ai binary sensor entity."""
reolink_connect.model = TEST_HOST_MODEL
reolink_connect.baichuan.smart_ai_state.return_value = True
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.BINARY_SENSOR]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
entity_id = f"{Platform.BINARY_SENSOR}.{TEST_NVR_NAME}_crossline_zone1_person"
assert hass.states.get(entity_id).state == STATE_ON
reolink_connect.baichuan.smart_ai_state.return_value = False
freezer.tick(DEVICE_UPDATE_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert hass.states.get(entity_id).state == STATE_OFF
async def test_tcp_callback( async def test_tcp_callback(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: MockConfigEntry, config_entry: MockConfigEntry,