2022-09-22 22:16:24 -04:00
|
|
|
"""The tests for Radarr sensor platform."""
|
|
|
|
from datetime import timedelta
|
2021-01-01 22:31:56 +01:00
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
from homeassistant.components.radarr.sensor import SENSOR_TYPES
|
|
|
|
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
import homeassistant.util.dt as dt_util
|
2017-06-05 01:44:24 -05:00
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
from . import setup_integration
|
2017-06-05 01:44:24 -05:00
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
from tests.common import async_fire_time_changed
|
|
|
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
2017-06-05 01:44:24 -05:00
|
|
|
|
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
async def test_sensors(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker):
|
|
|
|
"""Test for successfully setting up the Radarr platform."""
|
|
|
|
for description in SENSOR_TYPES.values():
|
|
|
|
description.entity_registry_enabled_default = True
|
|
|
|
await setup_integration(hass, aioclient_mock)
|
2017-06-05 01:44:24 -05:00
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
next_update = dt_util.utcnow() + timedelta(seconds=30)
|
|
|
|
async_fire_time_changed(hass, next_update)
|
|
|
|
await hass.async_block_till_done()
|
2019-07-31 12:25:30 -07:00
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
state = hass.states.get("sensor.radarr_disk_space_downloads")
|
|
|
|
assert state.state == "263.10"
|
|
|
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "GB"
|
|
|
|
state = hass.states.get("sensor.radarr_movies")
|
|
|
|
assert state.state == "1"
|
|
|
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Movies"
|
2017-06-05 01:44:24 -05:00
|
|
|
|
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
async def test_windows(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker):
|
|
|
|
"""Test for successfully setting up the Radarr platform on Windows."""
|
|
|
|
await setup_integration(hass, aioclient_mock, windows=True)
|
2017-06-05 01:44:24 -05:00
|
|
|
|
2022-09-22 22:16:24 -04:00
|
|
|
state = hass.states.get("sensor.radarr_disk_space_tv")
|
|
|
|
assert state.state == "263.10"
|