mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Only wait for import flows in setup of there is a config flow (#113780)
This commit is contained in:
parent
c52ee2a898
commit
879e5bc961
@ -427,15 +427,19 @@ async def _async_setup_component( # noqa: C901
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Flush out async_setup calling create_task. Fragile but covered by test.
|
if load_translations_task:
|
||||||
|
await load_translations_task
|
||||||
|
|
||||||
|
if integration.platforms_exists(("config_flow",)):
|
||||||
|
# If the integration has a config_flow, flush out async_setup calling create_task
|
||||||
|
# with an asyncio.sleep(0) so we can wait for import flows.
|
||||||
|
# Fragile but covered by test.
|
||||||
await asyncio.sleep(0)
|
await asyncio.sleep(0)
|
||||||
await hass.config_entries.flow.async_wait_import_flow_initialized(domain)
|
await hass.config_entries.flow.async_wait_import_flow_initialized(domain)
|
||||||
|
|
||||||
if load_translations_task:
|
# Add to components before the entry.async_setup
|
||||||
await load_translations_task
|
# call to avoid a deadlock when forwarding platforms
|
||||||
# Add to components before the entry.async_setup
|
hass.config.components.add(domain)
|
||||||
# call to avoid a deadlock when forwarding platforms
|
|
||||||
hass.config.components.add(domain)
|
|
||||||
|
|
||||||
if entries := hass.config_entries.async_entries(
|
if entries := hass.config_entries.async_entries(
|
||||||
domain, include_ignore=False, include_disabled=False
|
domain, include_ignore=False, include_disabled=False
|
||||||
|
@ -926,6 +926,8 @@ async def test_websocket_update_preferences_alexa_report_state(
|
|||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.async_sync_entities"
|
||||||
|
), patch(
|
||||||
(
|
(
|
||||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||||
".async_get_access_token"
|
".async_get_access_token"
|
||||||
@ -941,6 +943,7 @@ async def test_websocket_update_preferences_alexa_report_state(
|
|||||||
response = await client.receive_json()
|
response = await client.receive_json()
|
||||||
|
|
||||||
set_authorized_mock.assert_called_once_with(True)
|
set_authorized_mock.assert_called_once_with(True)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert response["success"]
|
assert response["success"]
|
||||||
|
|
||||||
|
@ -1121,6 +1121,7 @@ async def test_bootstrap_dependencies(
|
|||||||
# We patch the _import platform method to avoid loading the platform module
|
# We patch the _import platform method to avoid loading the platform module
|
||||||
# to avoid depending on non core components in the tests.
|
# to avoid depending on non core components in the tests.
|
||||||
mqtt_integration._import_platform = Mock()
|
mqtt_integration._import_platform = Mock()
|
||||||
|
mqtt_integration.platforms_exists = Mock(return_value=True)
|
||||||
|
|
||||||
integrations = {
|
integrations = {
|
||||||
"mqtt": {
|
"mqtt": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user