hass-core/tests/components/met_eireann/test_weather.py
Dylan Gore f3399aa8aa
Add a new weather integration - Met Éireann (#39429)
* Added a new weather integration - Met Éireann

* Fix codespell error

* Update met_eireann to use CoordinatorEntity

* Remove deprecated platform setup

* Fix merge conflict

* Remove unnecessary onboarding/home tracking code

* Use common strings for config flow

* Remove unnecessary code

* Switch to using unique IDs in config flow

* Use constants where possible

* Fix failing tests

* Fix isort errors

* Remove unnecessary DataUpdateCoordinator class

* Add device info

* Explicitly define forecast data

* Disable hourly forecast entity by default

* Update config flow to reflect requested changes

* Cleanup code

* Update entity naming to match other similar components

* Convert forecast time to UTC

* Fix test coverage

* Update test coverage

* Remove elevation conversion

* Update translations for additional clarity

* Remove en-GB translation
2021-04-05 23:23:57 +02:00

31 lines
1 KiB
Python

"""Test Met Éireann weather entity."""
from homeassistant.components.met_eireann.const import DOMAIN
from tests.common import MockConfigEntry
async def test_weather(hass, mock_weather):
"""Test weather entity."""
# Create a mock configuration for testing
mock_data = MockConfigEntry(
domain=DOMAIN,
data={"name": "Somewhere", "latitude": 10, "longitude": 20, "elevation": 0},
)
mock_data.add_to_hass(hass)
await hass.config_entries.async_setup(mock_data.entry_id)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids("weather")) == 1
assert len(mock_weather.mock_calls) == 4
# Test we do not track config
await hass.config.async_update(latitude=10, longitude=20)
await hass.async_block_till_done()
assert len(mock_weather.mock_calls) == 4
entry = hass.config_entries.async_entries()[0]
await hass.config_entries.async_remove(entry.entry_id)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids("weather")) == 0