mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 18:08:37 -04:00
Replace usages of datetime.now(UTC) with dt_util for Sonos (#172737)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"""Tests for the Sonos Media Player platform."""
|
||||
|
||||
from collections.abc import Generator
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
@@ -87,6 +86,7 @@ from homeassistant.helpers.device_registry import (
|
||||
DeviceRegistry,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .conftest import MockMusicServiceItem, MockSoCo, SoCoMockFactory, SonosMockEvent
|
||||
|
||||
@@ -1477,7 +1477,7 @@ async def test_position_updates(
|
||||
assert state.attributes[ATTR_MEDIA_POSITION] == 42
|
||||
# updated_at should be recent
|
||||
updated_at = state.attributes[ATTR_MEDIA_POSITION_UPDATED_AT]
|
||||
assert updated_at == datetime.now(UTC) # pylint: disable=home-assistant-enforce-utcnow
|
||||
assert updated_at == dt_util.utcnow()
|
||||
|
||||
# Position only updated by 1 second; should not update attributes
|
||||
new_track_info = current_track_info.copy()
|
||||
@@ -1507,8 +1507,7 @@ async def test_position_updates(
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.attributes[ATTR_MEDIA_POSITION] == 70
|
||||
# pylint: disable-next=home-assistant-enforce-utcnow
|
||||
assert state.attributes[ATTR_MEDIA_POSITION_UPDATED_AT] == datetime.now(UTC)
|
||||
assert state.attributes[ATTR_MEDIA_POSITION_UPDATED_AT] == dt_util.utcnow()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user