Fix zeroconf shutting down too early (#113638)

This commit is contained in:
J. Nick Koston 2024-03-16 14:42:27 -10:00 committed by GitHub
parent 513da0f71e
commit fa68c5633c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View file

@ -15,6 +15,7 @@ from zeroconf.asyncio import AsyncServiceInfo
from homeassistant.components import zeroconf
from homeassistant.const import (
EVENT_COMPONENT_LOADED,
EVENT_HOMEASSISTANT_CLOSE,
EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STARTED,
EVENT_HOMEASSISTANT_STOP,
@ -935,6 +936,11 @@ async def test_get_instance(hass: HomeAssistant, mock_async_zeroconf: None) -> N
)
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
await hass.async_block_till_done()
assert len(mock_async_zeroconf.ha_async_close.mock_calls) == 0
# Only shutdown at the close event so integrations have time
# to send out their goodbyes
hass.bus.async_fire(EVENT_HOMEASSISTANT_CLOSE)
await hass.async_block_till_done()
assert len(mock_async_zeroconf.ha_async_close.mock_calls) == 1