* Add new Forecasting to Weather * Add is_daytime for forecast_twice_daily * Fix test * Fix demo test * Adjust tests * Fix typing * Add demo * Mod demo more realistic * Fix test * Remove one weather * Fix weather example * kitchen_sink * Reverse demo partially * mod kitchen sink * Fix twice_daily * kitchen_sink * Add test weathers * Add twice daily to demo * dt_util * Fix names * Expose forecast via WS instead of as state attributes * Regularly update demo + kitchen_sink weather forecasts * Run linters * Fix rebase mistake * Improve demo test coverage * Improve weather test coverage * Exclude kitchen_sink weather from test coverage * Rename async_update_forecast to async_update_listeners * Add async_has_listeners helper * Revert "Add async_has_listeners helper" This reverts commit 52af3664bb06d9feac2c5ff963ee0022077c23ba. * Fix rebase mistake --------- Co-authored-by: Erik <erik@montnemery.com>
32 lines
1,001 B
Python
32 lines
1,001 B
Python
"""The tests for Weather platforms."""
|
|
|
|
|
|
from homeassistant.components.weather import ATTR_CONDITION_SUNNY
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from tests.testing_config.custom_components.test import weather as WeatherPlatform
|
|
|
|
|
|
async def create_entity(hass: HomeAssistant, **kwargs):
|
|
"""Create the weather entity to run tests on."""
|
|
kwargs = {
|
|
"native_temperature": None,
|
|
"native_temperature_unit": None,
|
|
"is_daytime": True,
|
|
**kwargs,
|
|
}
|
|
platform: WeatherPlatform = getattr(hass.components, "test.weather")
|
|
platform.init(empty=True)
|
|
platform.ENTITIES.append(
|
|
platform.MockWeatherMockForecast(
|
|
name="Test", condition=ATTR_CONDITION_SUNNY, **kwargs
|
|
)
|
|
)
|
|
|
|
entity0 = platform.ENTITIES[0]
|
|
assert await async_setup_component(
|
|
hass, "weather", {"weather": {"platform": "test"}}
|
|
)
|
|
await hass.async_block_till_done()
|
|
return entity0
|