Prepare for new aiohomekit lifecycle API (#66340)
This commit is contained in:
parent
2f220b27d4
commit
0daf20c0cc
11 changed files with 79 additions and 28 deletions
|
@ -4,7 +4,6 @@ from unittest.mock import patch
|
|||
|
||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||
from aiohomekit.model.services import ServicesTypes
|
||||
from aiohomekit.testing import FakeController
|
||||
|
||||
from homeassistant.components.homekit_controller.const import ENTITY_MAP
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||
|
@ -35,19 +34,16 @@ async def test_unload_on_stop(hass, utcnow):
|
|||
async def test_async_remove_entry(hass: HomeAssistant):
|
||||
"""Test unpairing a component."""
|
||||
helper = await setup_test_component(hass, create_motion_sensor_service)
|
||||
controller = helper.pairing.controller
|
||||
|
||||
hkid = "00:00:00:00:00:00"
|
||||
|
||||
with patch("aiohomekit.Controller") as controller_cls:
|
||||
# Setup a fake controller with 1 pairing
|
||||
controller = controller_cls.return_value = FakeController()
|
||||
await controller.add_paired_device([helper.accessory], hkid)
|
||||
assert len(controller.pairings) == 1
|
||||
assert len(controller.pairings) == 1
|
||||
|
||||
assert hkid in hass.data[ENTITY_MAP].storage_data
|
||||
assert hkid in hass.data[ENTITY_MAP].storage_data
|
||||
|
||||
# Remove it via config entry and number of pairings should go down
|
||||
await helper.config_entry.async_remove(hass)
|
||||
assert len(controller.pairings) == 0
|
||||
# Remove it via config entry and number of pairings should go down
|
||||
await helper.config_entry.async_remove(hass)
|
||||
assert len(controller.pairings) == 0
|
||||
|
||||
assert hkid not in hass.data[ENTITY_MAP].storage_data
|
||||
assert hkid not in hass.data[ENTITY_MAP].storage_data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue