mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Ensure harmony hub is ready before importing (#33537)
If the harmony hub was not ready for connection or was busy when importing from yaml, the import validation would fail would not be retried. To mitigate this scenario we now do the validation in async_setup_platform which allows us to raise PlatformNotReady so we can retry later.
This commit is contained in:
@@ -25,8 +25,7 @@ async def test_user_form(hass):
|
||||
|
||||
harmonyapi = _get_mock_harmonyapi(connect=True)
|
||||
with patch(
|
||||
"homeassistant.components.harmony.config_flow.HarmonyAPI",
|
||||
return_value=harmonyapi,
|
||||
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
|
||||
), patch(
|
||||
"homeassistant.components.harmony.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
@@ -53,8 +52,7 @@ async def test_form_import(hass):
|
||||
|
||||
harmonyapi = _get_mock_harmonyapi(connect=True)
|
||||
with patch(
|
||||
"homeassistant.components.harmony.config_flow.HarmonyAPI",
|
||||
return_value=harmonyapi,
|
||||
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
|
||||
), patch(
|
||||
"homeassistant.components.harmony.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
@@ -68,9 +66,11 @@ async def test_form_import(hass):
|
||||
"name": "friend",
|
||||
"activity": "Watch TV",
|
||||
"delay_secs": 0.9,
|
||||
"unique_id": "555234534543",
|
||||
},
|
||||
)
|
||||
|
||||
assert result["result"].unique_id == "555234534543"
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["title"] == "friend"
|
||||
assert result["data"] == {
|
||||
@@ -94,8 +94,7 @@ async def test_form_ssdp(hass):
|
||||
harmonyapi = _get_mock_harmonyapi(connect=True)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.harmony.config_flow.HarmonyAPI",
|
||||
return_value=harmonyapi,
|
||||
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -114,8 +113,7 @@ async def test_form_ssdp(hass):
|
||||
}
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.harmony.config_flow.HarmonyAPI",
|
||||
return_value=harmonyapi,
|
||||
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
|
||||
), patch(
|
||||
"homeassistant.components.harmony.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
@@ -141,8 +139,7 @@ async def test_form_cannot_connect(hass):
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.harmony.config_flow.HarmonyAPI",
|
||||
side_effect=CannotConnect,
|
||||
"homeassistant.components.harmony.util.HarmonyAPI", side_effect=CannotConnect,
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
|
||||
Reference in New Issue
Block a user