1
mirror of https://github.com/home-assistant/core synced 2024-10-07 10:13:38 +02:00

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