Improve google calendar config flow timeout error messages (#75364)

This commit is contained in:
Allen Porter 2022-07-18 02:44:51 -07:00 committed by GitHub
parent 943e0b9cf7
commit ca5065a627
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View file

@ -242,7 +242,7 @@ async def test_code_error(
mock_code_flow: Mock,
component_setup: ComponentSetup,
) -> None:
"""Test successful creds setup."""
"""Test server error setting up the oauth flow."""
assert await component_setup()
with patch(
@ -256,6 +256,25 @@ async def test_code_error(
assert result.get("reason") == "oauth_error"
async def test_timeout_error(
hass: HomeAssistant,
mock_code_flow: Mock,
component_setup: ComponentSetup,
) -> None:
"""Test timeout error setting up the oauth flow."""
assert await component_setup()
with patch(
"homeassistant.components.google.api.OAuth2WebServerFlow.step1_get_device_and_user_codes",
side_effect=TimeoutError(),
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result.get("type") == "abort"
assert result.get("reason") == "timeout_connect"
@pytest.mark.parametrize("code_expiration_delta", [datetime.timedelta(seconds=50)])
async def test_expired_after_exchange(
hass: HomeAssistant,