mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Freeze time for whirlpool test to avoid fail (#97935)
This commit is contained in:
parent
b2d2de990d
commit
3969de6c76
@ -2,6 +2,7 @@
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
import pytest
|
||||||
from whirlpool.washerdryer import MachineState
|
from whirlpool.washerdryer import MachineState
|
||||||
|
|
||||||
from homeassistant.components.whirlpool.sensor import SCAN_INTERVAL
|
from homeassistant.components.whirlpool.sensor import SCAN_INTERVAL
|
||||||
@ -325,6 +326,7 @@ async def test_no_restore_state(
|
|||||||
assert state.state != "unknown"
|
assert state.state != "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.freeze_time("2022-11-30 00:00:00")
|
||||||
async def test_callback(
|
async def test_callback(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_sensor_api_instances: MagicMock,
|
mock_sensor_api_instances: MagicMock,
|
||||||
@ -377,8 +379,8 @@ async def test_callback(
|
|||||||
assert state.state == time
|
assert state.state == time
|
||||||
|
|
||||||
# Test timestamp change for > 60 seconds.
|
# Test timestamp change for > 60 seconds.
|
||||||
mock_sensor1_api.get_attribute.return_value = "120"
|
mock_sensor1_api.get_attribute.return_value = "125"
|
||||||
callback()
|
callback()
|
||||||
state = hass.states.get("sensor.washer_end_time")
|
state = hass.states.get("sensor.washer_end_time")
|
||||||
newtime = utc_from_timestamp(as_timestamp(time) + 60)
|
newtime = utc_from_timestamp(as_timestamp(time) + 65)
|
||||||
assert state.state == newtime.isoformat()
|
assert state.state == newtime.isoformat()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user