mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add AEMET OpenData integration (#45074)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2f40f44670
commit
eecf07d7df
44
tests/components/aemet/test_init.py
Normal file
44
tests/components/aemet/test_init.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Define tests for the AEMET OpenData init."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.components.aemet.const import DOMAIN
|
||||
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .util import aemet_requests_mock
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
CONFIG = {
|
||||
CONF_NAME: "aemet",
|
||||
CONF_API_KEY: "foo",
|
||||
CONF_LATITUDE: 40.30403754,
|
||||
CONF_LONGITUDE: -3.72935236,
|
||||
}
|
||||
|
||||
|
||||
async def test_unload_entry(hass):
|
||||
"""Test that the options form."""
|
||||
|
||||
now = dt_util.parse_datetime("2021-01-09 12:00:00+00:00")
|
||||
with patch("homeassistant.util.dt.now", return_value=now), patch(
|
||||
"homeassistant.util.dt.utcnow", return_value=now
|
||||
), requests_mock.mock() as _m:
|
||||
aemet_requests_mock(_m)
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN, unique_id="aemet_unique_id", data=CONFIG
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert config_entry.state == ENTRY_STATE_LOADED
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert config_entry.state == ENTRY_STATE_NOT_LOADED
|
||||
Reference in New Issue
Block a user