Migrate vizio tests to use freezegun (#105417)
parent
038e55a2cb
commit
e3b09a5470
|
@ -6,6 +6,7 @@ from datetime import timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
|
from freezegun import freeze_time
|
||||||
import pytest
|
import pytest
|
||||||
from pyvizio.api.apps import AppConfig
|
from pyvizio.api.apps import AppConfig
|
||||||
from pyvizio.const import (
|
from pyvizio.const import (
|
||||||
|
@ -472,7 +473,7 @@ async def _test_update_availability_switch(
|
||||||
future_interval = timedelta(minutes=1)
|
future_interval = timedelta(minutes=1)
|
||||||
|
|
||||||
# Setup device as if time is right now
|
# Setup device as if time is right now
|
||||||
with patch("homeassistant.util.dt.utcnow", return_value=now):
|
with freeze_time(now):
|
||||||
await _test_setup_speaker(hass, initial_power_state)
|
await _test_setup_speaker(hass, initial_power_state)
|
||||||
|
|
||||||
# Clear captured logs so that only availability state changes are captured for
|
# Clear captured logs so that only availability state changes are captured for
|
||||||
|
@ -485,9 +486,7 @@ async def _test_update_availability_switch(
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.vizio.media_player.VizioAsync.get_power_state",
|
"homeassistant.components.vizio.media_player.VizioAsync.get_power_state",
|
||||||
return_value=final_power_state,
|
return_value=final_power_state,
|
||||||
), patch("homeassistant.util.dt.utcnow", return_value=future), patch(
|
), freeze_time(future):
|
||||||
"homeassistant.util.utcnow", return_value=future
|
|
||||||
):
|
|
||||||
async_fire_time_changed(hass, future)
|
async_fire_time_changed(hass, future)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
if final_power_state is None:
|
if final_power_state is None:
|
||||||
|
|
Loading…
Reference in New Issue