Migrate homematicip_cloud tests to use freezegun (#105592)
This commit is contained in:
parent
4ad16b56f2
commit
d33aa6b8e7
1 changed files with 10 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
"""Tests for HomematicIP Cloud button."""
|
"""Tests for HomematicIP Cloud button."""
|
||||||
from unittest.mock import patch
|
|
||||||
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
|
|
||||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
|
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
|
||||||
from homeassistant.components.button.const import SERVICE_PRESS
|
from homeassistant.components.button.const import SERVICE_PRESS
|
||||||
|
@ -11,7 +12,7 @@ from .helper import get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_garage_door_controller_button(
|
async def test_hmip_garage_door_controller_button(
|
||||||
hass: HomeAssistant, default_mock_hap_factory
|
hass: HomeAssistant, freezer: FrozenDateTimeFactory, default_mock_hap_factory
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test HomematicipGarageDoorControllerButton."""
|
"""Test HomematicipGarageDoorControllerButton."""
|
||||||
entity_id = "button.garagentor"
|
entity_id = "button.garagentor"
|
||||||
|
@ -28,7 +29,7 @@ async def test_hmip_garage_door_controller_button(
|
||||||
assert state.state == STATE_UNKNOWN
|
assert state.state == STATE_UNKNOWN
|
||||||
|
|
||||||
now = dt_util.parse_datetime("2021-01-09 12:00:00+00:00")
|
now = dt_util.parse_datetime("2021-01-09 12:00:00+00:00")
|
||||||
with patch("homeassistant.util.dt.utcnow", return_value=now):
|
freezer.move_to(now)
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
BUTTON_DOMAIN,
|
BUTTON_DOMAIN,
|
||||||
SERVICE_PRESS,
|
SERVICE_PRESS,
|
||||||
|
|
Loading…
Add table
Reference in a new issue