mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Do not patch asyncio.timeout
in govee light local test (#113819)
This commit is contained in:
parent
0fa395556d
commit
b35b4e8bfd
@ -9,7 +9,7 @@ from homeassistant.const import Platform
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DISCOVERY_TIMEOUT, DOMAIN
|
||||||
from .coordinator import GoveeLocalApiCoordinator
|
from .coordinator import GoveeLocalApiCoordinator
|
||||||
|
|
||||||
PLATFORMS: list[Platform] = [Platform.LIGHT]
|
PLATFORMS: list[Platform] = [Platform.LIGHT]
|
||||||
@ -26,7 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(delay=5):
|
async with asyncio.timeout(delay=DISCOVERY_TIMEOUT):
|
||||||
while not coordinator.devices:
|
while not coordinator.devices:
|
||||||
await asyncio.sleep(delay=1)
|
await asyncio.sleep(delay=1)
|
||||||
except TimeoutError as ex:
|
except TimeoutError as ex:
|
||||||
|
@ -15,13 +15,12 @@ from .const import (
|
|||||||
CONF_LISTENING_PORT_DEFAULT,
|
CONF_LISTENING_PORT_DEFAULT,
|
||||||
CONF_MULTICAST_ADDRESS_DEFAULT,
|
CONF_MULTICAST_ADDRESS_DEFAULT,
|
||||||
CONF_TARGET_PORT_DEFAULT,
|
CONF_TARGET_PORT_DEFAULT,
|
||||||
|
DISCOVERY_TIMEOUT,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DISCOVERY_TIMEOUT = 5
|
|
||||||
|
|
||||||
|
|
||||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||||
"""Return if there are devices that can be discovered."""
|
"""Return if there are devices that can be discovered."""
|
||||||
|
@ -11,3 +11,4 @@ CONF_LISTENING_PORT_DEFAULT = 4002
|
|||||||
CONF_DISCOVERY_INTERVAL_DEFAULT = 60
|
CONF_DISCOVERY_INTERVAL_DEFAULT = 60
|
||||||
|
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
DISCOVERY_TIMEOUT = 5
|
||||||
|
@ -131,8 +131,8 @@ async def test_light_setup_retry(
|
|||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.govee_light_local.asyncio.timeout",
|
"homeassistant.components.govee_light_local.DISCOVERY_TIMEOUT",
|
||||||
side_effect=TimeoutError,
|
0,
|
||||||
):
|
):
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user