Disconnect homekit_controller devices on the stop event (#49244)
This commit is contained in:
parent
54322f84c5
commit
e234fc6e7e
2 changed files with 41 additions and 0 deletions
29
tests/components/homekit_controller/test_init.py
Normal file
29
tests/components/homekit_controller/test_init.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
"""Tests for homekit_controller init."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||
from aiohomekit.model.services import ServicesTypes
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||
|
||||
from tests.components.homekit_controller.common import setup_test_component
|
||||
|
||||
|
||||
def create_motion_sensor_service(accessory):
|
||||
"""Define motion characteristics as per page 225 of HAP spec."""
|
||||
service = accessory.add_service(ServicesTypes.MOTION_SENSOR)
|
||||
cur_state = service.add_char(CharacteristicsTypes.MOTION_DETECTED)
|
||||
cur_state.value = 0
|
||||
|
||||
|
||||
async def test_unload_on_stop(hass, utcnow):
|
||||
"""Test async_unload is called on stop."""
|
||||
await setup_test_component(hass, create_motion_sensor_service)
|
||||
with patch(
|
||||
"homeassistant.components.homekit_controller.HKDevice.async_unload"
|
||||
) as async_unlock_mock:
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert async_unlock_mock.called
|
Loading…
Add table
Add a link
Reference in a new issue