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