Use aiopyarr for sonarr (#65349)
This commit is contained in:
parent
c14912471d
commit
f30681dae7
20 changed files with 464 additions and 345 deletions
|
@ -1,7 +1,7 @@
|
|||
"""Test the Sonarr config flow."""
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from sonarr import SonarrAccessRestricted, SonarrError
|
||||
from aiopyarr import ArrAuthenticationException, ArrException
|
||||
|
||||
from homeassistant.components.sonarr.const import (
|
||||
CONF_UPCOMING_DAYS,
|
||||
|
@ -11,7 +11,7 @@ from homeassistant.components.sonarr.const import (
|
|||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_SOURCE, CONF_VERIFY_SSL
|
||||
from homeassistant.const import CONF_API_KEY, CONF_SOURCE, CONF_URL, CONF_VERIFY_SSL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import (
|
||||
RESULT_TYPE_ABORT,
|
||||
|
@ -38,7 +38,7 @@ async def test_cannot_connect(
|
|||
hass: HomeAssistant, mock_sonarr_config_flow: MagicMock
|
||||
) -> None:
|
||||
"""Test we show user form on connection error."""
|
||||
mock_sonarr_config_flow.update.side_effect = SonarrError
|
||||
mock_sonarr_config_flow.async_get_system_status.side_effect = ArrException
|
||||
|
||||
user_input = MOCK_USER_INPUT.copy()
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -56,7 +56,9 @@ async def test_invalid_auth(
|
|||
hass: HomeAssistant, mock_sonarr_config_flow: MagicMock
|
||||
) -> None:
|
||||
"""Test we show user form on invalid auth."""
|
||||
mock_sonarr_config_flow.update.side_effect = SonarrAccessRestricted
|
||||
mock_sonarr_config_flow.async_get_system_status.side_effect = (
|
||||
ArrAuthenticationException
|
||||
)
|
||||
|
||||
user_input = MOCK_USER_INPUT.copy()
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -74,7 +76,7 @@ async def test_unknown_error(
|
|||
hass: HomeAssistant, mock_sonarr_config_flow: MagicMock
|
||||
) -> None:
|
||||
"""Test we show user form on unknown error."""
|
||||
mock_sonarr_config_flow.update.side_effect = Exception
|
||||
mock_sonarr_config_flow.async_get_system_status.side_effect = Exception
|
||||
|
||||
user_input = MOCK_USER_INPUT.copy()
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -153,7 +155,7 @@ async def test_full_user_flow_implementation(
|
|||
assert result["title"] == "192.168.1.189"
|
||||
|
||||
assert result["data"]
|
||||
assert result["data"][CONF_HOST] == "192.168.1.189"
|
||||
assert result["data"][CONF_URL] == "http://192.168.1.189:8989"
|
||||
|
||||
|
||||
async def test_full_user_flow_advanced_options(
|
||||
|
@ -183,7 +185,7 @@ async def test_full_user_flow_advanced_options(
|
|||
assert result["title"] == "192.168.1.189"
|
||||
|
||||
assert result["data"]
|
||||
assert result["data"][CONF_HOST] == "192.168.1.189"
|
||||
assert result["data"][CONF_URL] == "http://192.168.1.189:8989"
|
||||
assert result["data"][CONF_VERIFY_SSL]
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue