Bump aiohomekit to 1.0.0 (#75198)
* Bump to 1.0.0rc1 * 1.0.0rc2 * fix one of the tests * simplify test * 1.0.0 Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
03e3ebb238
commit
ff297cb902
5 changed files with 16 additions and 55 deletions
|
@ -227,7 +227,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
if not await conn.async_setup():
|
||||
del hass.data[KNOWN_DEVICES][conn.unique_id]
|
||||
if (connection := getattr(conn.pairing, "connection")) and hasattr(
|
||||
if (connection := getattr(conn.pairing, "connection", None)) and hasattr(
|
||||
connection, "host"
|
||||
):
|
||||
raise ConfigEntryNotReady(
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "HomeKit Controller",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/homekit_controller",
|
||||
"requirements": ["aiohomekit==0.7.22"],
|
||||
"requirements": ["aiohomekit==1.0.0"],
|
||||
"zeroconf": ["_hap._tcp.local.", "_hap._udp.local."],
|
||||
"after_dependencies": ["zeroconf"],
|
||||
"codeowners": ["@Jc2k", "@bdraco"],
|
||||
|
|
|
@ -168,7 +168,7 @@ aioguardian==2022.03.2
|
|||
aioharmony==0.2.9
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
aiohomekit==0.7.22
|
||||
aiohomekit==1.0.0
|
||||
|
||||
# homeassistant.components.emulated_hue
|
||||
# homeassistant.components.http
|
||||
|
|
|
@ -152,7 +152,7 @@ aioguardian==2022.03.2
|
|||
aioharmony==0.2.9
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
aiohomekit==0.7.22
|
||||
aiohomekit==1.0.0
|
||||
|
||||
# homeassistant.components.emulated_hue
|
||||
# homeassistant.components.http
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
from aiohomekit import AccessoryDisconnectedError, exceptions
|
||||
from aiohomekit import AccessoryDisconnectedError
|
||||
from aiohomekit.model import Accessory
|
||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||
from aiohomekit.model.services import ServicesTypes
|
||||
from aiohomekit.testing import FakeController, FakeDiscovery, FakePairing
|
||||
from aiohomekit.testing import FakePairing
|
||||
|
||||
from homeassistant.components.homekit_controller.const import DOMAIN, ENTITY_MAP
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
@ -98,7 +98,7 @@ async def test_device_remove_devices(hass, hass_ws_client):
|
|||
)
|
||||
|
||||
|
||||
async def test_offline_device_raises(hass):
|
||||
async def test_offline_device_raises(hass, controller):
|
||||
"""Test an offline device raises ConfigEntryNotReady."""
|
||||
|
||||
is_connected = False
|
||||
|
@ -114,56 +114,17 @@ async def test_offline_device_raises(hass):
|
|||
def get_characteristics(self, chars, *args, **kwargs):
|
||||
raise AccessoryDisconnectedError("any")
|
||||
|
||||
class OfflineFakeDiscovery(FakeDiscovery):
|
||||
"""Fake discovery that returns an offline pairing."""
|
||||
|
||||
async def start_pairing(self, alias: str):
|
||||
if self.description.id in self.controller.pairings:
|
||||
raise exceptions.AlreadyPairedError(
|
||||
f"{self.description.id} already paired"
|
||||
)
|
||||
|
||||
async def finish_pairing(pairing_code):
|
||||
if pairing_code != self.pairing_code:
|
||||
raise exceptions.AuthenticationError("M4")
|
||||
pairing_data = {}
|
||||
pairing_data["AccessoryIP"] = self.info["address"]
|
||||
pairing_data["AccessoryPort"] = self.info["port"]
|
||||
pairing_data["Connection"] = "IP"
|
||||
|
||||
obj = self.controller.pairings[alias] = OfflineFakePairing(
|
||||
self.controller, pairing_data, self.accessories
|
||||
)
|
||||
return obj
|
||||
|
||||
return finish_pairing
|
||||
|
||||
class OfflineFakeController(FakeController):
|
||||
"""Fake controller that always returns a discovery with a pairing that always returns False for is_connected."""
|
||||
|
||||
def add_device(self, accessories):
|
||||
device_id = "00:00:00:00:00:00"
|
||||
discovery = self.discoveries[device_id] = OfflineFakeDiscovery(
|
||||
self,
|
||||
device_id,
|
||||
accessories=accessories,
|
||||
)
|
||||
return discovery
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.homekit_controller.utils.Controller"
|
||||
) as controller:
|
||||
fake_controller = controller.return_value = OfflineFakeController()
|
||||
with patch("aiohomekit.testing.FakePairing", OfflineFakePairing):
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
accessory = Accessory.create_with_info(
|
||||
"TestDevice", "example.com", "Test", "0001", "0.1"
|
||||
)
|
||||
create_alive_service(accessory)
|
||||
|
||||
config_entry, _ = await setup_test_accessories_with_controller(
|
||||
hass, [accessory], fake_controller
|
||||
hass, [accessory], controller
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert config_entry.state == ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue