1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Simplify and improve AEMET coordinator updates (#99273)

This commit is contained in:
Álvaro Fernández Rojas
2023-08-29 15:43:14 +02:00
committed by GitHub
parent 98cb5b4b5d
commit fae82731e1
6 changed files with 108 additions and 144 deletions

View File

@@ -1,6 +1,8 @@
"""Define tests for the AEMET OpenData init."""
from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory
from homeassistant.components.aemet.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
@@ -41,3 +43,29 @@ async def test_unload_entry(hass: HomeAssistant) -> None:
await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.NOT_LOADED
async def test_init_town_not_found(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test TownNotFound 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=mock_api_call,
):
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