Use freezegun in fully_kiosk tests (#99031)
This commit is contained in:
parent
1f9c180233
commit
3b07181d87
2 changed files with 12 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Test the Fully Kiosk Browser binary sensors."""
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from fullykiosk import FullyKioskError
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||
|
@ -15,13 +16,13 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
async def test_binary_sensors(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
mock_fully_kiosk: MagicMock,
|
||||
init_integration: MockConfigEntry,
|
||||
) -> None:
|
||||
|
@ -76,7 +77,8 @@ async def test_binary_sensors(
|
|||
|
||||
# Test unknown/missing data
|
||||
mock_fully_kiosk.getDeviceInfo.return_value = {}
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + UPDATE_INTERVAL)
|
||||
freezer.tick(UPDATE_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("binary_sensor.amazon_fire_plugged_in")
|
||||
|
@ -85,7 +87,8 @@ async def test_binary_sensors(
|
|||
|
||||
# Test failed update
|
||||
mock_fully_kiosk.getDeviceInfo.side_effect = FullyKioskError("error", "status")
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + UPDATE_INTERVAL)
|
||||
freezer.tick(UPDATE_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("binary_sensor.amazon_fire_plugged_in")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Test the Fully Kiosk Browser sensors."""
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from fullykiosk import FullyKioskError
|
||||
|
||||
from homeassistant.components.fully_kiosk.const import DOMAIN, UPDATE_INTERVAL
|
||||
|
@ -25,6 +26,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
|||
|
||||
async def test_sensors_sensors(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
mock_fully_kiosk: MagicMock,
|
||||
init_integration: MockConfigEntry,
|
||||
) -> None:
|
||||
|
@ -141,7 +143,8 @@ async def test_sensors_sensors(
|
|||
|
||||
# Test unknown/missing data
|
||||
mock_fully_kiosk.getDeviceInfo.return_value = {}
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + UPDATE_INTERVAL)
|
||||
freezer.tick(UPDATE_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.amazon_fire_internal_storage_free_space")
|
||||
|
@ -150,7 +153,8 @@ async def test_sensors_sensors(
|
|||
|
||||
# Test failed update
|
||||
mock_fully_kiosk.getDeviceInfo.side_effect = FullyKioskError("error", "status")
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + UPDATE_INTERVAL)
|
||||
freezer.tick(UPDATE_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.amazon_fire_internal_storage_free_space")
|
||||
|
|
Loading…
Add table
Reference in a new issue