mirror of
https://github.com/jdejaegh/irm-kmi-ha.git
synced 2025-06-27 03:35:56 +02:00
Merge with origin/main
This commit is contained in:
commit
f651968b4d
4 changed files with 3310 additions and 2 deletions
|
@ -279,8 +279,8 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
|
|||
tz = await dt.async_get_time_zone('Europe/Brussels')
|
||||
day = dt.now(time_zone=tz).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
|
||||
for f in data:
|
||||
if 'dateShow' in f:
|
||||
for idx, f in enumerate(data):
|
||||
if 'dateShow' in f and idx > 0:
|
||||
day = day + timedelta(days=1)
|
||||
|
||||
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 @@ async def test_hourly_forecast() -> None:
|
|||
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(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
|
|
Loading…
Add table
Reference in a new issue