Migrate homekit_controller tests to use freezegun (#105646)
This commit is contained in:
parent
08ca3678da
commit
d322cb5fdf
22 changed files with 152 additions and 197 deletions
|
@ -1,9 +1,9 @@
|
|||
"""HomeKit controller session fixtures."""
|
||||
import datetime
|
||||
from unittest import mock
|
||||
import unittest.mock
|
||||
|
||||
from aiohomekit.testing import FakeController
|
||||
from freezegun import freeze_time
|
||||
import pytest
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
@ -13,14 +13,13 @@ from tests.components.light.conftest import mock_light_profiles # noqa: F401
|
|||
pytest.register_assert_rewrite("tests.components.homekit_controller.common")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def utcnow(request):
|
||||
@pytest.fixture(autouse=True)
|
||||
def freeze_time_in_future(request):
|
||||
"""Freeze time at a known point."""
|
||||
now = dt_util.utcnow()
|
||||
start_dt = datetime.datetime(now.year + 1, 1, 1, 0, 0, 0, tzinfo=now.tzinfo)
|
||||
with mock.patch("homeassistant.util.dt.utcnow") as dt_utcnow:
|
||||
dt_utcnow.return_value = start_dt
|
||||
yield dt_utcnow
|
||||
with freeze_time(start_dt) as frozen_time:
|
||||
yield frozen_time
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue