mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 05:35:11 +02:00
Reduce google calendar test flake (#67310)
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
"""Support for Google - Calendar Event Devices."""
|
"""Support for Google - Calendar Event Devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
@@ -28,7 +30,7 @@ from homeassistant.const import (
|
|||||||
CONF_OFFSET,
|
CONF_OFFSET,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import generate_entity_id
|
from homeassistant.helpers.entity import generate_entity_id
|
||||||
@@ -196,6 +198,8 @@ def do_authentication(
|
|||||||
notification_id=NOTIFICATION_ID,
|
notification_id=NOTIFICATION_ID,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
listener: CALLBACK_TYPE | None = None
|
||||||
|
|
||||||
def step2_exchange(now: datetime) -> None:
|
def step2_exchange(now: datetime) -> None:
|
||||||
"""Keep trying to validate the user_code until it expires."""
|
"""Keep trying to validate the user_code until it expires."""
|
||||||
_LOGGER.debug("Attempting to validate user code")
|
_LOGGER.debug("Attempting to validate user code")
|
||||||
@@ -212,6 +216,7 @@ def do_authentication(
|
|||||||
title=NOTIFICATION_TITLE,
|
title=NOTIFICATION_TITLE,
|
||||||
notification_id=NOTIFICATION_ID,
|
notification_id=NOTIFICATION_ID,
|
||||||
)
|
)
|
||||||
|
assert listener
|
||||||
listener()
|
listener()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -224,6 +229,7 @@ def do_authentication(
|
|||||||
storage = Storage(hass.config.path(TOKEN_FILE))
|
storage = Storage(hass.config.path(TOKEN_FILE))
|
||||||
storage.put(credentials)
|
storage.put(credentials)
|
||||||
do_setup(hass, hass_config, config)
|
do_setup(hass, hass_config, config)
|
||||||
|
assert listener
|
||||||
listener()
|
listener()
|
||||||
persistent_notification.create(
|
persistent_notification.create(
|
||||||
hass,
|
hass,
|
||||||
@@ -236,7 +242,7 @@ def do_authentication(
|
|||||||
)
|
)
|
||||||
|
|
||||||
listener = track_utc_time_change(
|
listener = track_utc_time_change(
|
||||||
hass, step2_exchange, second=range(0, 60, dev_flow.interval)
|
hass, step2_exchange, second=range(1, 60, dev_flow.interval)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Reference in New Issue
Block a user