Reduce google calendar test flake (#67310)

pull/67281/head
Allen Porter 2022-02-26 13:23:11 -08:00 committed by GitHub
parent 1ee4f47f8b
commit 648aa0cae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,6 @@
"""Support for Google - Calendar Event Devices."""
from __future__ import annotations
from collections.abc import Mapping
from datetime import datetime, timedelta, timezone
from enum import Enum
@ -28,7 +30,7 @@ from homeassistant.const import (
CONF_OFFSET,
Platform,
)
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, ServiceCall
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import generate_entity_id
@ -196,6 +198,8 @@ def do_authentication(
notification_id=NOTIFICATION_ID,
)
listener: CALLBACK_TYPE | None = None
def step2_exchange(now: datetime) -> None:
"""Keep trying to validate the user_code until it expires."""
_LOGGER.debug("Attempting to validate user code")
@ -212,6 +216,7 @@ def do_authentication(
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID,
)
assert listener
listener()
return
@ -224,6 +229,7 @@ def do_authentication(
storage = Storage(hass.config.path(TOKEN_FILE))
storage.put(credentials)
do_setup(hass, hass_config, config)
assert listener
listener()
persistent_notification.create(
hass,
@ -236,7 +242,7 @@ def do_authentication(
)
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