2022-09-23 02:16:24 +00:00
|
|
|
"""The tests for Radarr sensor platform."""
|
2023-07-31 16:44:03 +00:00
|
|
|
import pytest
|
2021-01-01 21:31:56 +00:00
|
|
|
|
2023-10-08 17:39:56 +00:00
|
|
|
from homeassistant.components.sensor import (
|
|
|
|
ATTR_STATE_CLASS,
|
|
|
|
SensorDeviceClass,
|
|
|
|
SensorStateClass,
|
|
|
|
)
|
2022-09-25 14:11:53 +00:00
|
|
|
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_UNIT_OF_MEASUREMENT
|
2022-09-23 02:16:24 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2017-06-05 06:44:24 +00:00
|
|
|
|
2022-09-23 02:16:24 +00:00
|
|
|
from . import setup_integration
|
2017-06-05 06:44:24 +00:00
|
|
|
|
2022-09-23 02:16:24 +00:00
|
|
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
2017-06-05 06:44:24 +00:00
|
|
|
|
|
|
|
|
2023-12-05 15:51:51 +00:00
|
|
|
@pytest.mark.freeze_time("2021-12-03 00:00:00+00:00")
|
2023-07-31 16:44:03 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
("windows", "single", "root_folder"),
|
|
|
|
[
|
|
|
|
(
|
|
|
|
False,
|
|
|
|
False,
|
|
|
|
"downloads",
|
|
|
|
),
|
|
|
|
(
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
"downloads",
|
|
|
|
),
|
|
|
|
(
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
"tv",
|
|
|
|
),
|
|
|
|
(
|
|
|
|
True,
|
|
|
|
True,
|
|
|
|
"tv",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2022-09-25 14:11:53 +00:00
|
|
|
async def test_sensors(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
aioclient_mock: AiohttpClientMocker,
|
2023-03-26 13:21:19 +00:00
|
|
|
entity_registry_enabled_by_default: None,
|
2023-07-31 16:44:03 +00:00
|
|
|
windows: bool,
|
|
|
|
single: bool,
|
|
|
|
root_folder: str,
|
2023-02-15 10:14:04 +00:00
|
|
|
) -> None:
|
2022-09-23 02:16:24 +00:00
|
|
|
"""Test for successfully setting up the Radarr platform."""
|
2023-07-31 16:44:03 +00:00
|
|
|
await setup_integration(hass, aioclient_mock, windows=windows, single_return=single)
|
2017-06-05 06:44:24 +00:00
|
|
|
|
2023-07-31 16:44:03 +00:00
|
|
|
state = hass.states.get(f"sensor.mock_title_disk_space_{root_folder}")
|
2022-09-23 02:16:24 +00:00
|
|
|
assert state.state == "263.10"
|
|
|
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "GB"
|
2022-09-25 23:26:50 +00:00
|
|
|
state = hass.states.get("sensor.mock_title_movies")
|
2022-09-23 02:16:24 +00:00
|
|
|
assert state.state == "1"
|
|
|
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Movies"
|
2022-09-25 23:26:50 +00:00
|
|
|
state = hass.states.get("sensor.mock_title_start_time")
|
2022-09-25 14:11:53 +00:00
|
|
|
assert state.state == "2020-09-01T23:50:20+00:00"
|
|
|
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
|
2023-10-08 17:39:56 +00:00
|
|
|
state = hass.states.get("sensor.mock_title_queue")
|
|
|
|
assert state.state == "2"
|
|
|
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Movies"
|
|
|
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
|
|
|
|
|
|
|
|
|
2023-12-05 15:51:51 +00:00
|
|
|
@pytest.mark.freeze_time("2021-12-03 00:00:00+00:00")
|
2023-10-08 17:39:56 +00:00
|
|
|
async def test_windows(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test for successfully setting up the Radarr platform on Windows."""
|
|
|
|
await setup_integration(hass, aioclient_mock, windows=True)
|
|
|
|
|
|
|
|
state = hass.states.get("sensor.mock_title_disk_space_tv")
|
|
|
|
assert state.state == "263.10"
|