Avoid writing HomeKit state to disk unless its missing (#111970)

This commit is contained in:
J. Nick Koston
2024-03-21 09:19:55 -10:00
committed by GitHub
parent d0708b5b32
commit 9a863638f6
2 changed files with 27 additions and 6 deletions

View File

@@ -765,9 +765,16 @@ async def test_homekit_start(
f"{PATH_HOMEKIT}.async_show_setup_message"
) as mock_setup_msg, patch(
"pyhap.accessory_driver.AccessoryDriver.async_start"
) as hk_driver_start:
) as hk_driver_start, patch(
"pyhap.accessory_driver.AccessoryDriver.load"
) as load_mock, patch(
"pyhap.accessory_driver.AccessoryDriver.persist"
) as persist_mock, patch(f"{PATH_HOMEKIT}.os.path.exists", return_value=True):
await homekit.async_stop()
await homekit.async_start()
assert load_mock.called
assert not persist_mock.called
device = device_registry.async_get_device(
identifiers={(DOMAIN, entry.entry_id, BRIDGE_SERIAL_NUMBER)}
)