Improve sonarr sensor test (#39623)
* improve sonarr sensor test * Update test_sensor.py * Update test_sensor.py * Update test_sensor.py * Update test_sensor.py * Update test_sensor.py * Update test_sensor.pypull/39632/head
parent
35e84d0427
commit
c1b8497aaa
|
@ -4,11 +4,8 @@ from datetime import timedelta
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.components.sonarr.const import (
|
from homeassistant.components.sonarr.const import CONF_BASE_PATH, DOMAIN
|
||||||
CONF_BASE_PATH,
|
from homeassistant.config_entries import ENTRY_STATE_LOADED
|
||||||
CONF_UPCOMING_DAYS,
|
|
||||||
DOMAIN,
|
|
||||||
)
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ICON,
|
ATTR_ICON,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
|
@ -23,6 +20,8 @@ from tests.async_mock import patch
|
||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed
|
||||||
from tests.components.sonarr import (
|
from tests.components.sonarr import (
|
||||||
MOCK_SENSOR_CONFIG,
|
MOCK_SENSOR_CONFIG,
|
||||||
|
_patch_async_setup,
|
||||||
|
_patch_async_setup_entry,
|
||||||
mock_connection,
|
mock_connection,
|
||||||
setup_integration,
|
setup_integration,
|
||||||
)
|
)
|
||||||
|
@ -36,6 +35,8 @@ async def test_import_from_sensor_component(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test import from sensor platform."""
|
"""Test import from sensor platform."""
|
||||||
mock_connection(aioclient_mock)
|
mock_connection(aioclient_mock)
|
||||||
|
|
||||||
|
with _patch_async_setup(), _patch_async_setup_entry():
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, SENSOR_DOMAIN, {SENSOR_DOMAIN: MOCK_SENSOR_CONFIG}
|
hass, SENSOR_DOMAIN, {SENSOR_DOMAIN: MOCK_SENSOR_CONFIG}
|
||||||
)
|
)
|
||||||
|
@ -44,10 +45,8 @@ async def test_import_from_sensor_component(
|
||||||
entries = hass.config_entries.async_entries(DOMAIN)
|
entries = hass.config_entries.async_entries(DOMAIN)
|
||||||
assert len(entries) == 1
|
assert len(entries) == 1
|
||||||
|
|
||||||
|
assert entries[0].state == ENTRY_STATE_LOADED
|
||||||
assert entries[0].data[CONF_BASE_PATH] == "/api"
|
assert entries[0].data[CONF_BASE_PATH] == "/api"
|
||||||
assert entries[0].options[CONF_UPCOMING_DAYS] == 3
|
|
||||||
|
|
||||||
assert hass.states.get(UPCOMING_ENTITY_ID)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_sensors(
|
async def test_sensors(
|
||||||
|
|
Loading…
Reference in New Issue