Skip to content

Commit

Permalink
Set the default time zone for evohome tests (home-assistant#126679)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Sep 27, 2024
1 parent bedfbfd commit d799b1a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 28 deletions.
16 changes: 15 additions & 1 deletion tests/components/evohome/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from collections.abc import AsyncGenerator, Callable
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from http import HTTPMethod
from typing import TYPE_CHECKING, Any
from unittest.mock import MagicMock, patch
Expand All @@ -15,6 +15,7 @@
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
Expand Down Expand Up @@ -121,6 +122,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),
Expand Down
54 changes: 27 additions & 27 deletions tests/components/evohome/snapshots/test_init.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit d799b1a

Please sign in to comment.