Ensure metoffice daily are returned once daily (#72440)
* ensure metoffice daily are returned once daily * Fixes metoffice tests for MODE_DAILY
This commit is contained in:
parent
f43cc18aa3
commit
66b02ecff0
2 changed files with 28 additions and 21 deletions
|
@ -7,6 +7,7 @@ import datapoint
|
|||
from homeassistant.helpers.update_coordinator import UpdateFailed
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .const import MODE_3HOURLY
|
||||
from .data import MetOfficeData
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -39,6 +40,9 @@ def fetch_data(connection: datapoint.Manager, site, mode) -> MetOfficeData:
|
|||
for day in forecast.days
|
||||
for timestep in day.timesteps
|
||||
if timestep.date > time_now
|
||||
and (
|
||||
mode == MODE_3HOURLY or timestep.date.hour > 6
|
||||
) # ensures only one result per day in MODE_DAILY
|
||||
],
|
||||
site,
|
||||
)
|
||||
|
|
|
@ -163,16 +163,17 @@ async def test_one_weather_site_running(hass, requests_mock):
|
|||
assert weather.attributes.get("humidity") == 50
|
||||
|
||||
# Also has Forecasts added - again, just pick out 1 entry to check
|
||||
assert len(weather.attributes.get("forecast")) == 8
|
||||
# ensures that daily filters out multiple results per day
|
||||
assert len(weather.attributes.get("forecast")) == 4
|
||||
|
||||
assert (
|
||||
weather.attributes.get("forecast")[7]["datetime"] == "2020-04-29T12:00:00+00:00"
|
||||
weather.attributes.get("forecast")[3]["datetime"] == "2020-04-29T12:00:00+00:00"
|
||||
)
|
||||
assert weather.attributes.get("forecast")[7]["condition"] == "rainy"
|
||||
assert weather.attributes.get("forecast")[7]["precipitation_probability"] == 59
|
||||
assert weather.attributes.get("forecast")[7]["temperature"] == 13
|
||||
assert weather.attributes.get("forecast")[7]["wind_speed"] == 13
|
||||
assert weather.attributes.get("forecast")[7]["wind_bearing"] == "SE"
|
||||
assert weather.attributes.get("forecast")[3]["condition"] == "rainy"
|
||||
assert weather.attributes.get("forecast")[3]["precipitation_probability"] == 59
|
||||
assert weather.attributes.get("forecast")[3]["temperature"] == 13
|
||||
assert weather.attributes.get("forecast")[3]["wind_speed"] == 13
|
||||
assert weather.attributes.get("forecast")[3]["wind_bearing"] == "SE"
|
||||
|
||||
|
||||
@freeze_time(datetime.datetime(2020, 4, 25, 12, tzinfo=datetime.timezone.utc))
|
||||
|
@ -258,16 +259,17 @@ async def test_two_weather_sites_running(hass, requests_mock):
|
|||
assert weather.attributes.get("humidity") == 50
|
||||
|
||||
# Also has Forecasts added - again, just pick out 1 entry to check
|
||||
assert len(weather.attributes.get("forecast")) == 8
|
||||
# ensures that daily filters out multiple results per day
|
||||
assert len(weather.attributes.get("forecast")) == 4
|
||||
|
||||
assert (
|
||||
weather.attributes.get("forecast")[7]["datetime"] == "2020-04-29T12:00:00+00:00"
|
||||
weather.attributes.get("forecast")[3]["datetime"] == "2020-04-29T12:00:00+00:00"
|
||||
)
|
||||
assert weather.attributes.get("forecast")[7]["condition"] == "rainy"
|
||||
assert weather.attributes.get("forecast")[7]["precipitation_probability"] == 59
|
||||
assert weather.attributes.get("forecast")[7]["temperature"] == 13
|
||||
assert weather.attributes.get("forecast")[7]["wind_speed"] == 13
|
||||
assert weather.attributes.get("forecast")[7]["wind_bearing"] == "SE"
|
||||
assert weather.attributes.get("forecast")[3]["condition"] == "rainy"
|
||||
assert weather.attributes.get("forecast")[3]["precipitation_probability"] == 59
|
||||
assert weather.attributes.get("forecast")[3]["temperature"] == 13
|
||||
assert weather.attributes.get("forecast")[3]["wind_speed"] == 13
|
||||
assert weather.attributes.get("forecast")[3]["wind_bearing"] == "SE"
|
||||
|
||||
# King's Lynn 3-hourly weather platform expected results
|
||||
weather = hass.states.get("weather.met_office_king_s_lynn_3_hourly")
|
||||
|
@ -305,13 +307,14 @@ async def test_two_weather_sites_running(hass, requests_mock):
|
|||
assert weather.attributes.get("humidity") == 75
|
||||
|
||||
# All should have Forecast added - again, just picking out 1 entry to check
|
||||
assert len(weather.attributes.get("forecast")) == 8
|
||||
# ensures daily filters out multiple results per day
|
||||
assert len(weather.attributes.get("forecast")) == 4
|
||||
|
||||
assert (
|
||||
weather.attributes.get("forecast")[5]["datetime"] == "2020-04-28T12:00:00+00:00"
|
||||
weather.attributes.get("forecast")[2]["datetime"] == "2020-04-28T12:00:00+00:00"
|
||||
)
|
||||
assert weather.attributes.get("forecast")[5]["condition"] == "cloudy"
|
||||
assert weather.attributes.get("forecast")[5]["precipitation_probability"] == 14
|
||||
assert weather.attributes.get("forecast")[5]["temperature"] == 11
|
||||
assert weather.attributes.get("forecast")[5]["wind_speed"] == 7
|
||||
assert weather.attributes.get("forecast")[5]["wind_bearing"] == "ESE"
|
||||
assert weather.attributes.get("forecast")[2]["condition"] == "cloudy"
|
||||
assert weather.attributes.get("forecast")[2]["precipitation_probability"] == 14
|
||||
assert weather.attributes.get("forecast")[2]["temperature"] == 11
|
||||
assert weather.attributes.get("forecast")[2]["wind_speed"] == 7
|
||||
assert weather.attributes.get("forecast")[2]["wind_bearing"] == "ESE"
|
||||
|
|
Loading…
Add table
Reference in a new issue