Migrate homekit to use async_at_started (#113102)

This commit is contained in:
J. Nick Koston 2024-03-11 14:08:02 -10:00 committed by GitHub
parent 5dc44500c3
commit 6e59d1cb29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 112 additions and 103 deletions

View file

@ -347,7 +347,7 @@ async def test_homekit_with_single_advertise_ips(
)
entry.add_to_hass(hass)
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
mock_driver.async_start = AsyncMock()
hk_driver.async_start = AsyncMock()
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
@ -386,7 +386,7 @@ async def test_homekit_with_many_advertise_ips(
)
entry.add_to_hass(hass)
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
mock_driver.async_start = AsyncMock()
hk_driver.async_start = AsyncMock()
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
@ -2043,6 +2043,7 @@ async def test_reload(hass: HomeAssistant, mock_async_zeroconf: None) -> None:
"homeassistant.components.network.async_get_source_ip", return_value="1.2.3.4"
):
mock_homekit.return_value = homekit = Mock()
type(homekit).async_start = AsyncMock()
assert await async_setup_component(
hass, "homekit", {"homekit": {CONF_NAME: "reloadable", CONF_PORT: 12345}}
)
@ -2065,16 +2066,15 @@ async def test_reload(hass: HomeAssistant, mock_async_zeroconf: None) -> None:
yaml_path = get_fixture_path("configuration.yaml", "homekit")
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path), patch(
f"{PATH_HOMEKIT}.HomeKit"
) as mock_homekit2, patch.object(homekit.bridge, "add_accessory"), patch(
f"{PATH_HOMEKIT}.async_show_setup_message"
), patch(
) as mock_homekit2, patch(f"{PATH_HOMEKIT}.async_show_setup_message"), patch(
f"{PATH_HOMEKIT}.get_accessory",
), patch(
), patch(f"{PATH_HOMEKIT}.async_port_is_available", return_value=True), patch(
"pyhap.accessory_driver.AccessoryDriver.async_start",
), patch(
"homeassistant.components.network.async_get_source_ip", return_value="1.2.3.4"
):
mock_homekit2.return_value = homekit = Mock()
type(homekit).async_start = AsyncMock()
await hass.services.async_call(
"homekit",
SERVICE_RELOAD,