mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Fix unbound local variable in Acmeda config flow (#145729)
This commit is contained in:
parent
07fd1f99df
commit
4300e846e6
@ -40,9 +40,10 @@ class AcmedaFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
entry.unique_id for entry in self._async_current_entries()
|
||||
}
|
||||
|
||||
hubs: list[aiopulse.Hub] = []
|
||||
with suppress(TimeoutError):
|
||||
async with timeout(5):
|
||||
hubs: list[aiopulse.Hub] = [
|
||||
hubs = [
|
||||
hub
|
||||
async for hub in aiopulse.Hub.discover()
|
||||
if hub.id not in already_configured
|
||||
|
@ -49,6 +49,21 @@ async def test_show_form_no_hubs(hass: HomeAssistant, mock_hub_discover) -> None
|
||||
assert len(mock_hub_discover.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_timeout_fetching_hub(hass: HomeAssistant, mock_hub_discover) -> None:
|
||||
"""Test that flow aborts if no hubs are discovered."""
|
||||
mock_hub_discover.side_effect = TimeoutError
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
# Check we performed the discovery
|
||||
assert len(mock_hub_discover.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_hub_run")
|
||||
async def test_show_form_one_hub(hass: HomeAssistant, mock_hub_discover) -> None:
|
||||
"""Test that a config is created when one hub discovered."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user