Cancel config entry retry, platform retry, and polling at the stop event (#49138)
This commit is contained in:
parent
0b4b071c02
commit
44beff31c2
6 changed files with 143 additions and 13 deletions
|
@ -8,7 +8,11 @@ from unittest.mock import AsyncMock, Mock, patch
|
|||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import ENTITY_MATCH_ALL, ENTITY_MATCH_NONE
|
||||
from homeassistant.const import (
|
||||
ENTITY_MATCH_ALL,
|
||||
ENTITY_MATCH_NONE,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers import discovery
|
||||
|
@ -487,3 +491,25 @@ async def test_register_entity_service(hass):
|
|||
DOMAIN, "hello", {"area_id": ENTITY_MATCH_NONE, "some": "data"}, blocking=True
|
||||
)
|
||||
assert len(calls) == 2
|
||||
|
||||
|
||||
async def test_platforms_shutdown_on_stop(hass):
|
||||
"""Test that we shutdown platforms on stop."""
|
||||
platform1_setup = Mock(side_effect=[PlatformNotReady, PlatformNotReady, None])
|
||||
mock_integration(hass, MockModule("mod1"))
|
||||
mock_entity_platform(hass, "test_domain.mod1", MockPlatform(platform1_setup))
|
||||
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
|
||||
await component.async_setup({DOMAIN: {"platform": "mod1"}})
|
||||
await hass.async_block_till_done()
|
||||
assert len(platform1_setup.mock_calls) == 1
|
||||
assert "test_domain.mod1" not in hass.config.components
|
||||
|
||||
with patch.object(
|
||||
component._platforms[DOMAIN], "async_shutdown"
|
||||
) as mock_async_shutdown:
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_async_shutdown.called
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue