Migrate snooze config flow to use eager_start (#115658)
This commit is contained in:
parent
7188d62340
commit
b829f1030b
2 changed files with 10 additions and 3 deletions
|
@ -132,7 +132,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Wait for device to enter pairing mode."""
|
"""Wait for device to enter pairing mode."""
|
||||||
if not self._pairing_task:
|
if not self._pairing_task:
|
||||||
self._pairing_task = self.hass.async_create_task(
|
self._pairing_task = self.hass.async_create_task(
|
||||||
self._async_wait_for_pairing_mode(), eager_start=False
|
self._async_wait_for_pairing_mode()
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self._pairing_task.done():
|
if not self._pairing_task.done():
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from asyncio import Event
|
from asyncio import Event, sleep
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
@ -298,9 +298,16 @@ async def _test_pairs(
|
||||||
async def _test_pairs_timeout(
|
async def _test_pairs_timeout(
|
||||||
hass: HomeAssistant, flow_id: str, user_input: dict | None = None
|
hass: HomeAssistant, flow_id: str, user_input: dict | None = None
|
||||||
) -> str:
|
) -> str:
|
||||||
|
async def _async_process_advertisements(
|
||||||
|
_hass, _callback, _matcher, _mode, _timeout
|
||||||
|
):
|
||||||
|
"""Simulate a timeout waiting for pairing mode."""
|
||||||
|
await sleep(0)
|
||||||
|
raise TimeoutError
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.snooz.config_flow.async_process_advertisements",
|
"homeassistant.components.snooz.config_flow.async_process_advertisements",
|
||||||
side_effect=TimeoutError(),
|
_async_process_advertisements,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
flow_id, user_input=user_input or {}
|
flow_id, user_input=user_input or {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue