Do not patch asyncio.timeout in govee light local test (#113819)

This commit is contained in:
Jan-Philipp Benecke 2024-03-19 18:24:36 +01:00 committed by GitHub
parent 0fa395556d
commit b35b4e8bfd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 6 deletions

View File

@ -9,7 +9,7 @@ from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from .const import DOMAIN
from .const import DISCOVERY_TIMEOUT, DOMAIN
from .coordinator import GoveeLocalApiCoordinator
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()
try:
async with asyncio.timeout(delay=5):
async with asyncio.timeout(delay=DISCOVERY_TIMEOUT):
while not coordinator.devices:
await asyncio.sleep(delay=1)
except TimeoutError as ex:

View File

@ -15,13 +15,12 @@ from .const import (
CONF_LISTENING_PORT_DEFAULT,
CONF_MULTICAST_ADDRESS_DEFAULT,
CONF_TARGET_PORT_DEFAULT,
DISCOVERY_TIMEOUT,
DOMAIN,
)
_LOGGER = logging.getLogger(__name__)
DISCOVERY_TIMEOUT = 5
async def _async_has_devices(hass: HomeAssistant) -> bool:
"""Return if there are devices that can be discovered."""

View File

@ -11,3 +11,4 @@ CONF_LISTENING_PORT_DEFAULT = 4002
CONF_DISCOVERY_INTERVAL_DEFAULT = 60
SCAN_INTERVAL = timedelta(seconds=30)
DISCOVERY_TIMEOUT = 5

View File

@ -131,8 +131,8 @@ async def test_light_setup_retry(
entry.add_to_hass(hass)
with patch(
"homeassistant.components.govee_light_local.asyncio.timeout",
side_effect=TimeoutError,
"homeassistant.components.govee_light_local.DISCOVERY_TIMEOUT",
0,
):
await hass.config_entries.async_setup(entry.entry_id)
assert entry.state is ConfigEntryState.SETUP_RETRY