* Use async_connect in newly bumped 0.5.8 UPB library. * Fix tests. * Fix date being wrong after midnight for Environment Canada * Fix typing. * Add test. * Formatting. * Remove tests until can be added properly. * Add weather tests back. * Fix tests * Change of tactic for determining previous day's data. --------- Co-authored-by: G Johansson <goran.johansson@shiftit.se>
68 lines
1.6 KiB
Python
68 lines
1.6 KiB
Python
"""Test weather."""
|
|
|
|
import json
|
|
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
from homeassistant.components.weather import (
|
|
DOMAIN as WEATHER_DOMAIN,
|
|
SERVICE_GET_FORECASTS,
|
|
)
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from . import init_integration
|
|
|
|
from tests.common import load_fixture
|
|
|
|
|
|
async def test_forecast_daily(
|
|
hass: HomeAssistant,
|
|
snapshot: SnapshotAssertion,
|
|
) -> None:
|
|
"""Test basic forecast."""
|
|
|
|
ec_data = json.loads(
|
|
load_fixture("environment_canada/current_conditions_data.json")
|
|
)
|
|
|
|
# First entry in test data is a half day; we don't want that for this test
|
|
del ec_data["daily_forecasts"][0]
|
|
|
|
await init_integration(hass, ec_data)
|
|
|
|
response = await hass.services.async_call(
|
|
WEATHER_DOMAIN,
|
|
SERVICE_GET_FORECASTS,
|
|
{
|
|
"entity_id": "weather.home_forecast",
|
|
"type": "daily",
|
|
},
|
|
blocking=True,
|
|
return_response=True,
|
|
)
|
|
assert response == snapshot
|
|
|
|
|
|
async def test_forecast_daily_with_some_previous_days_data(
|
|
hass: HomeAssistant,
|
|
snapshot: SnapshotAssertion,
|
|
) -> None:
|
|
"""Test forecast with half day at start."""
|
|
|
|
ec_data = json.loads(
|
|
load_fixture("environment_canada/current_conditions_data.json")
|
|
)
|
|
|
|
await init_integration(hass, ec_data)
|
|
|
|
response = await hass.services.async_call(
|
|
WEATHER_DOMAIN,
|
|
SERVICE_GET_FORECASTS,
|
|
{
|
|
"entity_id": "weather.home_forecast",
|
|
"type": "daily",
|
|
},
|
|
blocking=True,
|
|
return_response=True,
|
|
)
|
|
assert response == snapshot
|