Use builtin TimeoutError [a-d] (#109678)

This commit is contained in:
Marc Mueller 2024-02-05 11:31:33 +01:00 committed by GitHub
parent 41a256a3ff
commit c82933175d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 97 additions and 137 deletions

View file

@ -1,5 +1,4 @@
"""Tests for the HTTP API for the cloud component."""
import asyncio
from copy import deepcopy
from http import HTTPStatus
from typing import Any
@ -346,7 +345,7 @@ async def test_login_view_request_timeout(
) -> None:
"""Test request timeout while trying to log in."""
cloud_client = await hass_client()
cloud.login.side_effect = asyncio.TimeoutError
cloud.login.side_effect = TimeoutError
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
@ -409,7 +408,7 @@ async def test_logout_view_request_timeout(
) -> None:
"""Test timeout while logging out."""
cloud_client = await hass_client()
cloud.logout.side_effect = asyncio.TimeoutError
cloud.logout.side_effect = TimeoutError
req = await cloud_client.post("/api/cloud/logout")
@ -524,7 +523,7 @@ async def test_register_view_request_timeout(
) -> None:
"""Test timeout while registering."""
cloud_client = await hass_client()
cloud.auth.async_register.side_effect = asyncio.TimeoutError
cloud.auth.async_register.side_effect = TimeoutError
req = await cloud_client.post(
"/api/cloud/register", json={"email": "hello@bla.com", "password": "falcon42"}
@ -590,7 +589,7 @@ async def test_forgot_password_view_request_timeout(
) -> None:
"""Test timeout while forgot password."""
cloud_client = await hass_client()
cloud.auth.async_forgot_password.side_effect = asyncio.TimeoutError
cloud.auth.async_forgot_password.side_effect = TimeoutError
req = await cloud_client.post(
"/api/cloud/forgot_password", json={"email": "hello@bla.com"}
@ -674,7 +673,7 @@ async def test_resend_confirm_view_request_timeout(
) -> None:
"""Test timeout while resend confirm."""
cloud_client = await hass_client()
cloud.auth.async_resend_email_confirm.side_effect = asyncio.TimeoutError
cloud.auth.async_resend_email_confirm.side_effect = TimeoutError
req = await cloud_client.post(
"/api/cloud/resend_confirm", json={"email": "hello@bla.com"}
@ -1400,7 +1399,7 @@ async def test_sync_alexa_entities_timeout(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_sync_entities"
),
side_effect=asyncio.TimeoutError,
side_effect=TimeoutError,
):
await client.send_json({"id": 5, "type": "cloud/alexa/sync"})
response = await client.receive_json()
@ -1484,7 +1483,7 @@ async def test_thingtalk_convert_timeout(
with patch(
"homeassistant.components.cloud.http_api.thingtalk.async_convert",
side_effect=asyncio.TimeoutError,
side_effect=TimeoutError,
):
await client.send_json(
{"id": 5, "type": "cloud/thingtalk/convert", "query": "some-data"}