Skip to content

Commit 1103f0c

Browse files
committed
Code and test updates
1 parent 2435755 commit 1103f0c

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

tests/components/plugwise/test_climate.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@
2222
HVACAction,
2323
HVACMode,
2424
)
25+
from homeassistant.components.plugwise.climate import PlugwiseClimateExtraStoredData
2526
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
26-
from homeassistant.core import HomeAssistant
27+
from homeassistant.core import HomeAssistant, State
2728
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
2829
from homeassistant.helpers import entity_registry as er
30+
2931
from syrupy.assertion import SnapshotAssertion
3032

31-
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
33+
from tests.common import (
34+
MockConfigEntry,
35+
async_fire_time_changed,
36+
mock_restore_cache_with_extra_data,
37+
snapshot_platform,
38+
)
3239

3340
HA_PLUGWISE_SMILE_ASYNC_UPDATE = (
3441
"homeassistant.components.plugwise.coordinator.Smile.async_update"
@@ -122,7 +129,6 @@ async def test_adam_climate_entity_climate_changes(
122129
blocking=True,
123130
)
124131

125-
126132
async def test_adam_climate_adjust_negative_testing(
127133
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
128134
) -> None:
@@ -138,6 +144,28 @@ async def test_adam_climate_adjust_negative_testing(
138144
)
139145

140146

147+
@pytest.mark.parametrize("chosen_env", ["m_adam_heating"], indirect=True)
148+
@pytest.mark.parametrize("cooling_present", [False], indirect=True)
149+
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
150+
async def test_adam_restore_state_climate(
151+
hass: HomeAssistant, mock_smile_adam_heat_cool: MagicMock, init_integration: MockConfigEntry
152+
) -> None:
153+
"""Test restore_state for climate."""
154+
mock_restore_cache_with_extra_data(
155+
hass,
156+
[
157+
(
158+
State("climate.living_room", "heat"),
159+
PlugwiseClimateExtraStoredData(
160+
last_active_schedule="Weekschema", previous_action_mode="heat",
161+
).as_dict(),
162+
),
163+
],
164+
)
165+
assert (state := hass.states.get("climate.living_room"))
166+
assert state.state == "heat"
167+
168+
141169
@pytest.mark.parametrize("chosen_env", ["m_adam_heating"], indirect=True)
142170
@pytest.mark.parametrize("cooling_present", [False], indirect=True)
143171
@pytest.mark.parametrize("platforms", [(CLIMATE_DOMAIN,)])

0 commit comments

Comments
 (0)