Update switch tests to avoid patching utcnow (#93491)
This commit is contained in:
parent
bf2c12dcf2
commit
0160c8c14f
1 changed files with 4 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
"""The test for switch device automation."""
|
||||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
from freezegun import freeze_time
|
||||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
|
@ -232,8 +232,7 @@ async def test_if_fires_on_for_condition(
|
|||
|
||||
ent1, ent2, ent3 = platform.ENTITIES
|
||||
|
||||
with patch("homeassistant.core.dt_util.utcnow") as mock_utcnow:
|
||||
mock_utcnow.return_value = point1
|
||||
with freeze_time(point1) as freezer:
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
|
@ -271,7 +270,7 @@ async def test_if_fires_on_for_condition(
|
|||
assert len(calls) == 0
|
||||
|
||||
# Time travel 10 secs into the future
|
||||
mock_utcnow.return_value = point2
|
||||
freezer.move_to(point2)
|
||||
hass.bus.async_fire("test_event1")
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
|
@ -282,7 +281,7 @@ async def test_if_fires_on_for_condition(
|
|||
assert len(calls) == 0
|
||||
|
||||
# Time travel 20 secs into the future
|
||||
mock_utcnow.return_value = point3
|
||||
freezer.move_to(point3)
|
||||
hass.bus.async_fire("test_event1")
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
|
Loading…
Add table
Reference in a new issue