Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -184,6 +184,7 @@ async def test_platform_warn_slow_setup(hass):
|
||||
|
||||
with patch.object(hass.loop, "call_later") as mock_call:
|
||||
await component.async_setup({DOMAIN: {"platform": "platform"}})
|
||||
await hass.async_block_till_done()
|
||||
assert mock_call.called
|
||||
|
||||
# mock_calls[0] is the warning message for component setup
|
||||
@@ -209,6 +210,7 @@ async def test_platform_error_slow_setup(hass, caplog):
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
mock_entity_platform(hass, "test_domain.test_platform", platform)
|
||||
await component.async_setup({DOMAIN: {"platform": "test_platform"}})
|
||||
await hass.async_block_till_done()
|
||||
assert len(called) == 1
|
||||
assert "test_domain.test_platform" not in hass.config.components
|
||||
assert "test_platform is taking longer than 0 seconds" in caplog.text
|
||||
@@ -242,6 +244,7 @@ async def test_parallel_updates_async_platform(hass):
|
||||
component._platforms = {}
|
||||
|
||||
await component.async_setup({DOMAIN: {"platform": "platform"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
handle = list(component._platforms.values())[-1]
|
||||
assert handle.parallel_updates is None
|
||||
@@ -268,6 +271,7 @@ async def test_parallel_updates_async_platform_with_constant(hass):
|
||||
component._platforms = {}
|
||||
|
||||
await component.async_setup({DOMAIN: {"platform": "platform"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
handle = list(component._platforms.values())[-1]
|
||||
|
||||
@@ -293,6 +297,7 @@ async def test_parallel_updates_sync_platform(hass):
|
||||
component._platforms = {}
|
||||
|
||||
await component.async_setup({DOMAIN: {"platform": "platform"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
handle = list(component._platforms.values())[-1]
|
||||
|
||||
@@ -319,6 +324,7 @@ async def test_parallel_updates_sync_platform_with_constant(hass):
|
||||
component._platforms = {}
|
||||
|
||||
await component.async_setup({DOMAIN: {"platform": "platform"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
handle = list(component._platforms.values())[-1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user