mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Migrate directv test to use freezegun (#105894)
This commit is contained in:
parent
556be26040
commit
0972dc5867
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.directv.media_player import (
|
from homeassistant.components.directv.media_player import (
|
||||||
@ -305,6 +306,7 @@ async def test_check_attributes(
|
|||||||
async def test_attributes_paused(
|
async def test_attributes_paused(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_now: dt_util.dt.datetime,
|
mock_now: dt_util.dt.datetime,
|
||||||
|
freezer: FrozenDateTimeFactory,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes while paused."""
|
"""Test attributes while paused."""
|
||||||
@ -315,11 +317,9 @@ async def test_attributes_paused(
|
|||||||
|
|
||||||
# Test to make sure that ATTR_MEDIA_POSITION_UPDATED_AT is not
|
# Test to make sure that ATTR_MEDIA_POSITION_UPDATED_AT is not
|
||||||
# updated if TV is paused.
|
# updated if TV is paused.
|
||||||
with patch(
|
freezer.move_to(mock_now + timedelta(minutes=5))
|
||||||
"homeassistant.util.dt.utcnow", return_value=mock_now + timedelta(minutes=5)
|
await async_media_pause(hass, CLIENT_ENTITY_ID)
|
||||||
):
|
await hass.async_block_till_done()
|
||||||
await async_media_pause(hass, CLIENT_ENTITY_ID)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get(CLIENT_ENTITY_ID)
|
state = hass.states.get(CLIENT_ENTITY_ID)
|
||||||
assert state.state == STATE_PAUSED
|
assert state.state == STATE_PAUSED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user