8000 Fix unbound local variable in Acmeda config flow (#145729) · home-assistant/core@4300e84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4300e84

Browse files
authored
Fix unbound local variable in Acmeda config flow (#145729)
1 parent 07fd1f9 commit 4300e84

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

homeassistant/components/acmeda/config_flow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ async def async_step_user(
4040
entry.unique_id for entry in self._async_current_entries()
4141
}
4242

43+
hubs: list[aiopulse.Hub] = []
4344
with suppress(TimeoutError):
4445
async with timeout(5):
45-
hubs: list[aiopulse.Hub] = [
46+
hubs = [
4647
hub
4748
async for hub in aiopulse.Hub.discover()
4849
if hub.id not in already_configured

tests/components/acmeda/test_config_flow.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ async def test_show_form_no_hubs(hass: HomeAssistant, mock_hub_discover) -> None
4949
assert len(mock_hub_discover.mock_calls) == 1
5050

5151

52+
async def test_timeout_fetching_hub(hass: HomeAssistant, mock_hub_discover) -> None:
53+
"""Test that flow aborts if no hubs are discovered."""
54+
mock_hub_discover.side_effect = TimeoutError
55+
56+
result = await hass.config_entries.flow.async_init(
57+
DOMAIN, context={"source": SOURCE_USER}
58+
)
59+
60+
assert result["type"] is FlowResultType.ABORT
61+
assert result["reason"] == "no_devices_found"
62+
63+
# Check we performed the discovery
64+
assert len(mock_hub_discover.mock_calls) == 1
65+
66+
5267
@pytest.mark.usefixtures("mock_hub_run")
5368
async def test_show_form_one_hub(hass: HomeAssistant, mock_hub_discover) -> None:
5469
"""Test that a config is created when one hub discovered."""

0 commit comments

Comments
 (0)
0