Migrate directv test to use freezegun (#105894)

This commit is contained in:
Jan-Philipp Benecke 2023-12-18 14:40:13 +01:00 committed by GitHub
parent 556be26040
commit 0972dc5867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ from __future__ import annotations
from datetime import datetime, timedelta
from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory
import pytest
from homeassistant.components.directv.media_player import (
@ -305,6 +306,7 @@ async def test_check_attributes(
async def test_attributes_paused(
hass: HomeAssistant,
mock_now: dt_util.dt.datetime,
freezer: FrozenDateTimeFactory,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""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
# updated if TV is paused.
with patch(
"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()
freezer.move_to(mock_now + timedelta(minutes=5))
await async_media_pause(hass, CLIENT_ENTITY_ID)
await hass.async_block_till_done()
state = hass.states.get(CLIENT_ENTITY_ID)
assert state.state == STATE_PAUSED