mirror of
https://github.com/jdejaegh/irm-kmi-ha.git
synced 2025-06-27 11:39:26 +02:00
parent
2e90931996
commit
afea4df5d2
4 changed files with 3310 additions and 2 deletions
|
@ -275,8 +275,8 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
|
||||||
forecasts = list()
|
forecasts = list()
|
||||||
day = datetime.now(tz=pytz.timezone('Europe/Brussels')).replace(hour=0, minute=0, second=0, microsecond=0)
|
day = datetime.now(tz=pytz.timezone('Europe/Brussels')).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
|
|
||||||
for f in data:
|
for idx, f in enumerate(data):
|
||||||
if 'dateShow' in f:
|
if 'dateShow' in f and idx > 0:
|
||||||
day = day + timedelta(days=1)
|
day = day + timedelta(days=1)
|
||||||
|
|
||||||
hour = f.get('hour', None)
|
hour = f.get('hour', None)
|
||||||
|
|
1632
tests/fixtures/midnight-bug-31-05-2024T00-13.json
vendored
Normal file
1632
tests/fixtures/midnight-bug-31-05-2024T00-13.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
1625
tests/fixtures/no-midnight-bug-31-05-2024T01-55.json
vendored
Normal file
1625
tests/fixtures/no-midnight-bug-31-05-2024T01-55.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -141,6 +141,57 @@ def test_hourly_forecast() -> None:
|
||||||
assert result[8] == expected
|
assert result[8] == expected
|
||||||
|
|
||||||
|
|
||||||
|
@freeze_time(datetime.fromisoformat('2024-05-31T01:50:00+02:00'))
|
||||||
|
def test_hourly_forecast_bis() -> None:
|
||||||
|
api_data = get_api_data("no-midnight-bug-31-05-2024T01-55.json").get('for', {}).get('hourly')
|
||||||
|
result = IrmKmiCoordinator.hourly_list_to_forecast(api_data)
|
||||||
|
|
||||||
|
assert isinstance(result, list)
|
||||||
|
|
||||||
|
times = ['2024-05-31T01:00:00+02:00', '2024-05-31T02:00:00+02:00', '2024-05-31T03:00:00+02:00',
|
||||||
|
'2024-05-31T04:00:00+02:00', '2024-05-31T05:00:00+02:00', '2024-05-31T06:00:00+02:00',
|
||||||
|
'2024-05-31T07:00:00+02:00', '2024-05-31T08:00:00+02:00', '2024-05-31T09:00:00+02:00']
|
||||||
|
|
||||||
|
actual = [f['datetime'] for f in result[:9]]
|
||||||
|
|
||||||
|
assert actual == times
|
||||||
|
|
||||||
|
|
||||||
|
@freeze_time(datetime.fromisoformat('2024-05-31T00:10:00+02:00'))
|
||||||
|
def test_hourly_forecast_midnight_bug() -> None:
|
||||||
|
# Related to https://github.com/jdejaegh/irm-kmi-ha/issues/38
|
||||||
|
api_data = get_api_data("midnight-bug-31-05-2024T00-13.json").get('for', {}).get('hourly')
|
||||||
|
result = IrmKmiCoordinator.hourly_list_to_forecast(api_data)
|
||||||
|
|
||||||
|
assert isinstance(result, list)
|
||||||
|
|
||||||
|
first = Forecast(
|
||||||
|
datetime='2024-05-31T00:00:00+02:00',
|
||||||
|
condition=ATTR_CONDITION_CLOUDY,
|
||||||
|
native_precipitation=0,
|
||||||
|
native_temperature=14,
|
||||||
|
native_templow=None,
|
||||||
|
native_wind_gust_speed=None,
|
||||||
|
native_wind_speed=10,
|
||||||
|
precipitation_probability=0,
|
||||||
|
wind_bearing=293,
|
||||||
|
native_pressure=1010,
|
||||||
|
is_daytime=False
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result[0] == first
|
||||||
|
|
||||||
|
times = ['2024-05-31T00:00:00+02:00', '2024-05-31T01:00:00+02:00', '2024-05-31T02:00:00+02:00',
|
||||||
|
'2024-05-31T03:00:00+02:00', '2024-05-31T04:00:00+02:00', '2024-05-31T05:00:00+02:00',
|
||||||
|
'2024-05-31T06:00:00+02:00', '2024-05-31T07:00:00+02:00', '2024-05-31T08:00:00+02:00']
|
||||||
|
|
||||||
|
actual = [f['datetime'] for f in result[:9]]
|
||||||
|
|
||||||
|
assert actual == times
|
||||||
|
|
||||||
|
assert result[24]['datetime'] == '2024-06-01T00:00:00+02:00'
|
||||||
|
|
||||||
|
|
||||||
async def test_refresh_succeed_even_when_pollen_and_radar_fail(
|
async def test_refresh_succeed_even_when_pollen_and_radar_fail(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
|
|
Loading…
Add table
Reference in a new issue