mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 09:58:07 -04:00
Handle timeouts on AEMET init (#102289)
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Define tests for the AEMET OpenData init."""
|
||||
import asyncio
|
||||
from unittest.mock import patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
@@ -70,3 +71,29 @@ async def test_init_town_not_found(
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id) is False
|
||||
|
||||
|
||||
async def test_init_api_timeout(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test API timeouts when loading the AEMET integration."""
|
||||
|
||||
hass.config.set_time_zone("UTC")
|
||||
freezer.move_to("2021-01-09 12:00:00+00:00")
|
||||
with patch(
|
||||
"homeassistant.components.aemet.AEMET.api_call",
|
||||
side_effect=asyncio.TimeoutError,
|
||||
):
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_API_KEY: "api-key",
|
||||
CONF_LATITUDE: "0.0",
|
||||
CONF_LONGITUDE: "0.0",
|
||||
CONF_NAME: "AEMET",
|
||||
},
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id) is False
|
||||
|
||||
Reference in New Issue
Block a user