Use freezegun in utility_meter tests (#105123)

This commit is contained in:
Jan-Philipp Benecke
2023-12-06 14:43:26 +01:00
committed by GitHub
parent 3f28354a00
commit a16819e0e5
2 changed files with 14 additions and 15 deletions

View File

@@ -2,8 +2,8 @@
from __future__ import annotations
from datetime import timedelta
from unittest.mock import patch
from freezegun import freeze_time
import pytest
from homeassistant.components.select import (
@@ -95,7 +95,7 @@ async def test_services(hass: HomeAssistant, meter) -> None:
await hass.async_block_till_done()
now = dt_util.utcnow() + timedelta(seconds=10)
with patch("homeassistant.util.dt.utcnow", return_value=now):
with freeze_time(now):
hass.states.async_set(
entity_id,
3,
@@ -116,7 +116,7 @@ async def test_services(hass: HomeAssistant, meter) -> None:
await hass.async_block_till_done()
now += timedelta(seconds=10)
with patch("homeassistant.util.dt.utcnow", return_value=now):
with freeze_time(now):
hass.states.async_set(
entity_id,
4,
@@ -144,7 +144,7 @@ async def test_services(hass: HomeAssistant, meter) -> None:
await hass.async_block_till_done()
now += timedelta(seconds=10)
with patch("homeassistant.util.dt.utcnow", return_value=now):
with freeze_time(now):
hass.states.async_set(
entity_id,
5,
@@ -221,7 +221,7 @@ async def test_services_config_entry(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
now = dt_util.utcnow() + timedelta(seconds=10)
with patch("homeassistant.util.dt.utcnow", return_value=now):
with freeze_time(now):
hass.states.async_set(
entity_id,
3,
@@ -242,7 +242,7 @@ async def test_services_config_entry(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
now += timedelta(seconds=10)
with patch("homeassistant.util.dt.utcnow", return_value=now):
with freeze_time(now):
hass.states.async_set(
entity_id,
4,
@@ -270,7 +270,7 @@ async def test_services_config_entry(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
now += timedelta(seconds=10)
with patch("homeassistant.util.dt.utcnow", return_value=now):
with freeze_time(now):
hass.states.async_set(
entity_id,
5,