Skip to content

Commit

Permalink
Update generic_hygrostat tests to avoid patching utcnow (#93476)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed May 24, 2023
1 parent cff72f9 commit dc3826f
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions tests/components/generic_hygrostat/test_humidifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The tests for the generic_hygrostat."""
import datetime
from unittest.mock import patch

from freezegun import freeze_time
import pytest
import voluptuous as vol

Expand Down Expand Up @@ -855,9 +855,7 @@ async def test_humidity_change_dry_trigger_on_long_enough(
fake_changed = datetime.datetime(
1970, 11, 11, 11, 11, 11, tzinfo=datetime.timezone.utc
)
with patch(
"homeassistant.helpers.condition.dt_util.utcnow", return_value=fake_changed
):
with freeze_time(fake_changed):
calls = await _setup_switch(hass, False)
_setup_sensor(hass, 35)
await hass.async_block_till_done()
Expand Down Expand Up @@ -893,9 +891,7 @@ async def test_humidity_change_dry_trigger_off_long_enough(
fake_changed = datetime.datetime(
1970, 11, 11, 11, 11, 11, tzinfo=datetime.timezone.utc
)
with patch(
"homeassistant.helpers.condition.dt_util.utcnow", return_value=fake_changed
):
with freeze_time(fake_changed):
calls = await _setup_switch(hass, True)
_setup_sensor(hass, 45)
await hass.async_block_till_done()
Expand Down Expand Up @@ -1021,9 +1017,7 @@ async def test_humidity_change_humidifier_trigger_on_long_enough(
fake_changed = datetime.datetime(
1970, 11, 11, 11, 11, 11, tzinfo=datetime.timezone.utc
)
with patch(
"homeassistant.helpers.condition.dt_util.utcnow", return_value=fake_changed
):
with freeze_time(fake_changed):
calls = await _setup_switch(hass, False)
_setup_sensor(hass, 45)
await hass.async_block_till_done()
Expand All @@ -1045,9 +1039,7 @@ async def test_humidity_change_humidifier_trigger_off_long_enough(
fake_changed = datetime.datetime(
1970, 11, 11, 11, 11, 11, tzinfo=datetime.timezone.utc
)
with patch(
"homeassistant.helpers.condition.dt_util.utcnow", return_value=fake_changed
):
with freeze_time(fake_changed):
calls = await _setup_switch(hass, True)
_setup_sensor(hass, 35)
await hass.async_block_till_done()
Expand Down

0 comments on commit dc3826f

Please sign in to comment.