mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Cancel config entry retry, platform retry, and polling at the stop event (#49138)
This commit is contained in:
@@ -685,6 +685,29 @@ async def test_reset_cancels_retry_setup_when_not_started(hass):
|
||||
assert ent_platform._async_cancel_retry_setup is None
|
||||
|
||||
|
||||
async def test_stop_shutdown_cancels_retry_setup_and_interval_listener(hass):
|
||||
"""Test that shutdown will cancel scheduled a setup retry and interval listener."""
|
||||
async_setup_entry = Mock(side_effect=PlatformNotReady)
|
||||
platform = MockPlatform(async_setup_entry=async_setup_entry)
|
||||
config_entry = MockConfigEntry()
|
||||
ent_platform = MockEntityPlatform(
|
||||
hass, platform_name=config_entry.domain, platform=platform
|
||||
)
|
||||
|
||||
with patch.object(entity_platform, "async_call_later") as mock_call_later:
|
||||
assert not await ent_platform.async_setup_entry(config_entry)
|
||||
|
||||
assert len(mock_call_later.mock_calls) == 1
|
||||
assert len(mock_call_later.return_value.mock_calls) == 0
|
||||
assert ent_platform._async_cancel_retry_setup is not None
|
||||
|
||||
await ent_platform.async_shutdown()
|
||||
|
||||
assert len(mock_call_later.return_value.mock_calls) == 1
|
||||
assert ent_platform._async_unsub_polling is None
|
||||
assert ent_platform._async_cancel_retry_setup is None
|
||||
|
||||
|
||||
async def test_not_fails_with_adding_empty_entities_(hass):
|
||||
"""Test for not fails on empty entities list."""
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
|
||||
Reference in New Issue
Block a user