Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the default time zone for evohome tests #126679

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
Expand All @@ -16,6 +16,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 @@ -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),
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 @@ -463,9 +463,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 @@ -546,9 +546,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 @@ -591,9 +591,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 @@ -755,9 +755,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 @@ -838,9 +838,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