mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
homekit_controller test cleanups (#32212)
This commit is contained in:
parent
e435f6eb67
commit
92a47f14bb
@ -3,7 +3,6 @@ import asyncio
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from aiohomekit.controller.ip import IpPairing
|
||||
from aiohomekit.exceptions import (
|
||||
AccessoryDisconnectedError,
|
||||
AccessoryNotFoundError,
|
||||
@ -15,7 +14,7 @@ from aiohomekit.model.services import ServicesTypes
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
|
||||
from .const import DOMAIN, ENTITY_MAP, HOMEKIT_ACCESSORY_DISPATCH
|
||||
from .const import CONTROLLER, DOMAIN, ENTITY_MAP, HOMEKIT_ACCESSORY_DISPATCH
|
||||
|
||||
DEFAULT_SCAN_INTERVAL = datetime.timedelta(seconds=60)
|
||||
RETRY_INTERVAL = 60 # seconds
|
||||
@ -66,7 +65,9 @@ class HKDevice:
|
||||
# don't want to mutate a dict owned by a config entry.
|
||||
self.pairing_data = pairing_data.copy()
|
||||
|
||||
self.pairing = IpPairing(self.pairing_data)
|
||||
self.pairing = hass.data[CONTROLLER].load_pairing(
|
||||
self.pairing_data["AccessoryPairingID"], self.pairing_data
|
||||
)
|
||||
|
||||
self.accessories = {}
|
||||
self.config_num = 0
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "HomeKit Controller",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/homekit_controller",
|
||||
"requirements": ["aiohomekit[IP]==0.2.11"],
|
||||
"requirements": ["aiohomekit[IP]==0.2.15"],
|
||||
"dependencies": [],
|
||||
"zeroconf": ["_hap._tcp.local."],
|
||||
"codeowners": ["@Jc2k"]
|
||||
|
@ -163,7 +163,7 @@ aioftp==0.12.0
|
||||
aioharmony==0.1.13
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
aiohomekit[IP]==0.2.11
|
||||
aiohomekit[IP]==0.2.15
|
||||
|
||||
# homeassistant.components.emulated_hue
|
||||
# homeassistant.components.http
|
||||
|
@ -62,7 +62,7 @@ aiobotocore==0.11.1
|
||||
aioesphomeapi==2.6.1
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
aiohomekit[IP]==0.2.11
|
||||
aiohomekit[IP]==0.2.15
|
||||
|
||||
# homeassistant.components.emulated_hue
|
||||
# homeassistant.components.http
|
||||
|
@ -98,11 +98,8 @@ async def setup_test_accessories(hass, accessories):
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
pairing_cls_loc = "homeassistant.components.homekit_controller.connection.IpPairing"
|
||||
with mock.patch(pairing_cls_loc) as pairing_cls:
|
||||
pairing_cls.return_value = pairing
|
||||
await config_entry.async_setup(hass)
|
||||
await hass.async_block_till_done()
|
||||
await config_entry.async_setup(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
return config_entry, pairing
|
||||
|
||||
|
@ -149,14 +149,8 @@ async def test_ecobee3_setup_connection_failure(hass):
|
||||
# a successful setup.
|
||||
|
||||
# We just advance time by 5 minutes so that the retry happens, rather
|
||||
# than manually invoking async_setup_entry - this means we need to
|
||||
# make sure the IpPairing mock is in place or we'll try to connect to
|
||||
# a real device. Normally this mocking is done by the helper in
|
||||
# setup_test_accessories.
|
||||
pairing_cls_loc = "homeassistant.components.homekit_controller.connection.IpPairing"
|
||||
with mock.patch(pairing_cls_loc) as pairing_cls:
|
||||
pairing_cls.return_value = pairing
|
||||
await time_changed(hass, 5 * 60)
|
||||
# than manually invoking async_setup_entry.
|
||||
await time_changed(hass, 5 * 60)
|
||||
|
||||
climate = entity_registry.async_get("climate.homew")
|
||||
assert climate.unique_id == "homekit-123456789012-16"
|
||||
|
Loading…
x
Reference in New Issue
Block a user