Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generic_hygrostat tests to avoid patching utcnow #93476

Merged
merged 2 commits into from
May 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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