Set the default time zone for evohome tests (#126679)

This commit is contained in:
David Bonnes 2024-09-27 12:44:47 +01:00 committed by GitHub
parent 94efd3e230
commit 2d16732972
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 28 deletions

View File

@ -3,7 +3,7 @@
from __future__ import annotations
from collections.abc import Callable
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from http import HTTPMethod
from typing import Any
from unittest.mock import MagicMock, patch
@ -16,6 +16,7 @@ import pytest
from homeassistant.components.evohome import CONF_PASSWORD, CONF_USERNAME, DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from homeassistant.util.json import JsonArrayType, JsonObjectType
from .const import ACCESS_TOKEN, REFRESH_TOKEN, USERNAME
@ -119,6 +120,19 @@ async def setup_evohome(
The class is mocked here to check the client was instantiated with the correct args.
"""
# set the time zone as for the active evohome location
loc_idx: int = test_config.get("location_idx", 0) # type: ignore[assignment]
try:
locn = user_locations_config_fixture(install)[loc_idx]
except IndexError:
if loc_idx == 0:
raise
locn = user_locations_config_fixture(install)[0]
utc_offset: int = locn["locationInfo"]["timeZone"]["currentOffsetMinutes"] # type: ignore[assignment, call-overload, index]
dt_util.set_default_time_zone(timezone(timedelta(minutes=utc_offset)))
with (
patch("homeassistant.components.evohome.evo.EvohomeClient") as mock_client,
patch("homeassistant.components.evohome.ev1.EvohomeClient", return_value=None),

View File

@ -62,9 +62,9 @@
'target_heat_temperature': 17.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -110,9 +110,9 @@
'target_heat_temperature': 17.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -157,12 +157,12 @@
'setpoint_status': dict({
'setpoint_mode': 'TemporaryOverride',
'target_heat_temperature': 21.0,
'until': '2022-03-07T11:00:00-08:00',
'until': '2022-03-07T20:00:00+01:00',
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -205,9 +205,9 @@
'target_heat_temperature': 17.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -250,9 +250,9 @@
'target_heat_temperature': 16.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -295,9 +295,9 @@
'target_heat_temperature': 16.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -340,9 +340,9 @@
'target_heat_temperature': 17.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -380,9 +380,9 @@
]),
'dhw_id': '3933910',
'setpoints': dict({
'next_sp_from': '2024-07-10T05:00:00-07:00',
'next_sp_from': '2024-07-10T13:00:00+01:00',
'next_sp_state': 'Off',
'this_sp_from': '2024-07-10T04:00:00-07:00',
'this_sp_from': '2024-07-10T12:00:00+01:00',
'this_sp_state': 'On',
}),
'state_status': dict({
@ -909,9 +909,9 @@
'target_heat_temperature': 21.5,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -992,9 +992,9 @@
'target_heat_temperature': 21.5,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T12:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+03:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-09T22:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+03:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -1037,9 +1037,9 @@
'target_heat_temperature': 21.5,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T12:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+03:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-09T22:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+03:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -1123,9 +1123,9 @@
'target_heat_temperature': 17.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T14:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+01:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-10T00:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+01:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({
@ -1206,9 +1206,9 @@
'target_heat_temperature': 15.0,
}),
'setpoints': dict({
'next_sp_from': '2024-07-10T13:10:00-07:00',
'next_sp_from': '2024-07-10T22:10:00+02:00',
'next_sp_temp': 18.6,
'this_sp_from': '2024-07-09T23:00:00-07:00',
'this_sp_from': '2024-07-10T08:00:00+02:00',
'this_sp_temp': 16.0,
}),
'temperature_status': dict({