Update prometheus tests to avoid patching utcnow (#93505)

This commit is contained in:
J. Nick Koston 2023-05-25 00:15:14 -05:00 committed by GitHub
parent 2bb46c8a9e
commit c63e3c3bf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ from http import HTTPStatus
from typing import Any from typing import Any
from unittest import mock from unittest import mock
from freezegun import freeze_time
import prometheus_client import prometheus_client
import pytest import pytest
@ -941,10 +942,7 @@ async def sensor_fixture(
suggested_object_id="radio_energy", suggested_object_id="radio_energy",
original_name="Radio Energy", original_name="Radio Energy",
) )
with mock.patch( with freeze_time(datetime.datetime(1970, 1, 2, tzinfo=dt_util.UTC)):
"homeassistant.util.dt.utcnow",
return_value=datetime.datetime(1970, 1, 2, tzinfo=dt_util.UTC),
):
set_state_with_entry(hass, sensor_3, 14) set_state_with_entry(hass, sensor_3, 14)
data["sensor_3"] = sensor_3 data["sensor_3"] = sensor_3