Bump aiopyarr to 22.9.0 (#79173)
This commit is contained in:
parent
0c191df598
commit
e360a4fa9e
9 changed files with 79 additions and 42 deletions
|
@ -5,7 +5,7 @@ from collections.abc import Mapping
|
|||
from typing import Any
|
||||
|
||||
from aiohttp import ClientConnectorError
|
||||
from aiopyarr import SystemStatus, exceptions
|
||||
from aiopyarr import exceptions
|
||||
from aiopyarr.lidarr_client import LidarrClient
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -54,15 +54,16 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
else:
|
||||
try:
|
||||
result = await validate_input(self.hass, user_input)
|
||||
if isinstance(result, tuple):
|
||||
if result := await validate_input(self.hass, user_input):
|
||||
user_input[CONF_API_KEY] = result[1]
|
||||
elif isinstance(result, str):
|
||||
errors = {"base": result}
|
||||
except exceptions.ArrAuthenticationException:
|
||||
errors = {"base": "invalid_auth"}
|
||||
except (ClientConnectorError, exceptions.ArrConnectionException):
|
||||
errors = {"base": "cannot_connect"}
|
||||
except exceptions.ArrWrongAppException:
|
||||
errors = {"base": "wrong_app"}
|
||||
except exceptions.ArrZeroConfException:
|
||||
errors = {"base": "zeroconf_failed"}
|
||||
except exceptions.ArrException:
|
||||
errors = {"base": "unknown"}
|
||||
if not errors:
|
||||
|
@ -95,7 +96,7 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def validate_input(
|
||||
hass: HomeAssistant, data: dict[str, Any]
|
||||
) -> tuple[str, str, str] | str | SystemStatus:
|
||||
) -> tuple[str, str, str] | None:
|
||||
"""Validate the user input allows us to connect.
|
||||
|
||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||
|
@ -108,4 +109,5 @@ async def validate_input(
|
|||
)
|
||||
if CONF_API_KEY not in data:
|
||||
return await lidarr.async_try_zeroconf()
|
||||
return await lidarr.async_get_system_status()
|
||||
await lidarr.async_get_system_status()
|
||||
return None
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "lidarr",
|
||||
"name": "Lidarr",
|
||||
"documentation": "https://www.home-assistant.io/integrations/lidarr",
|
||||
"requirements": ["aiopyarr==22.7.0"],
|
||||
"requirements": ["aiopyarr==22.9.0"],
|
||||
"codeowners": ["@tkdrob"],
|
||||
"config_flow": true,
|
||||
"iot_class": "local_polling",
|
||||
|
|
|
@ -62,15 +62,16 @@ class RadarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
else:
|
||||
try:
|
||||
result = await validate_input(self.hass, user_input)
|
||||
if isinstance(result, tuple):
|
||||
if result := await validate_input(self.hass, user_input):
|
||||
user_input[CONF_API_KEY] = result[1]
|
||||
elif isinstance(result, str):
|
||||
errors = {"base": result}
|
||||
except exceptions.ArrAuthenticationException:
|
||||
errors = {"base": "invalid_auth"}
|
||||
except (ClientConnectorError, exceptions.ArrConnectionException):
|
||||
errors = {"base": "cannot_connect"}
|
||||
except exceptions.ArrWrongAppException:
|
||||
errors = {"base": "wrong_app"}
|
||||
except exceptions.ArrZeroConfException:
|
||||
errors = {"base": "zeroconf_failed"}
|
||||
except exceptions.ArrException:
|
||||
errors = {"base": "unknown"}
|
||||
if not errors:
|
||||
|
@ -130,7 +131,7 @@ class RadarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def validate_input(
|
||||
hass: HomeAssistant, data: dict[str, Any]
|
||||
) -> tuple[str, str, str] | str | None:
|
||||
) -> tuple[str, str, str] | None:
|
||||
"""Validate the user input allows us to connect."""
|
||||
host_configuration = PyArrHostConfiguration(
|
||||
api_token=data.get(CONF_API_KEY, ""),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "radarr",
|
||||
"name": "Radarr",
|
||||
"documentation": "https://www.home-assistant.io/integrations/radarr",
|
||||
"requirements": ["aiopyarr==22.7.0"],
|
||||
"requirements": ["aiopyarr==22.9.0"],
|
||||
"codeowners": ["@tkdrob"],
|
||||
"config_flow": true,
|
||||
"iot_class": "local_polling",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Sonarr",
|
||||
"documentation": "https://www.home-assistant.io/integrations/sonarr",
|
||||
"codeowners": ["@ctalkington"],
|
||||
"requirements": ["aiopyarr==22.7.0"],
|
||||
"requirements": ["aiopyarr==22.9.0"],
|
||||
"config_flow": true,
|
||||
"quality_scale": "silver",
|
||||
"iot_class": "local_polling",
|
||||
|
|
|
@ -237,7 +237,7 @@ aiopvpc==3.0.0
|
|||
# homeassistant.components.lidarr
|
||||
# homeassistant.components.radarr
|
||||
# homeassistant.components.sonarr
|
||||
aiopyarr==22.7.0
|
||||
aiopyarr==22.9.0
|
||||
|
||||
# homeassistant.components.qnap_qsw
|
||||
aioqsw==0.2.2
|
||||
|
|
|
@ -212,7 +212,7 @@ aiopvpc==3.0.0
|
|||
# homeassistant.components.lidarr
|
||||
# homeassistant.components.radarr
|
||||
# homeassistant.components.sonarr
|
||||
aiopyarr==22.7.0
|
||||
aiopyarr==22.9.0
|
||||
|
||||
# homeassistant.components.qnap_qsw
|
||||
aioqsw==0.2.2
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Test Lidarr config flow."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from aiopyarr import ArrAuthenticationException, ArrConnectionException, ArrException
|
||||
from aiopyarr import exceptions
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.lidarr.const import DEFAULT_NAME, DOMAIN
|
||||
|
@ -45,7 +45,7 @@ async def test_flow_user_form(
|
|||
async def test_flow_user_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test invalid authentication."""
|
||||
with _patch_client() as client:
|
||||
client.side_effect = ArrAuthenticationException
|
||||
client.side_effect = exceptions.ArrAuthenticationException
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
|
@ -62,7 +62,7 @@ async def test_flow_user_invalid_auth(hass: HomeAssistant) -> None:
|
|||
async def test_flow_user_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test connection error."""
|
||||
with _patch_client() as client:
|
||||
client.side_effect = ArrConnectionException
|
||||
client.side_effect = exceptions.ArrConnectionException
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
|
@ -76,10 +76,44 @@ async def test_flow_user_cannot_connect(hass: HomeAssistant) -> None:
|
|||
assert result["errors"]["base"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_wrong_app(hass: HomeAssistant) -> None:
|
||||
"""Test we show user form on wrong app."""
|
||||
with patch(
|
||||
"homeassistant.components.lidarr.config_flow.LidarrClient.async_try_zeroconf",
|
||||
side_effect=exceptions.ArrWrongAppException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
data=MOCK_USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"]["base"] == "wrong_app"
|
||||
|
||||
|
||||
async def test_zero_conf_failure(hass: HomeAssistant) -> None:
|
||||
"""Test we show user form on api key retrieval failure."""
|
||||
with patch(
|
||||
"homeassistant.components.lidarr.config_flow.LidarrClient.async_try_zeroconf",
|
||||
side_effect=exceptions.ArrZeroConfException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
data=MOCK_USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"]["base"] == "zeroconf_failed"
|
||||
|
||||
|
||||
async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
|
||||
"""Test unknown error."""
|
||||
with _patch_client() as client:
|
||||
client.side_effect = ArrException
|
||||
client.side_effect = exceptions.ArrException
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
|
@ -93,23 +127,6 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
|
|||
assert result["errors"]["base"] == "unknown"
|
||||
|
||||
|
||||
async def test_flow_user_failed_zeroconf(hass: HomeAssistant) -> None:
|
||||
"""Test zero configuration failed."""
|
||||
with _patch_client() as client:
|
||||
client.return_value = "zeroconf_failed"
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
)
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input=CONF_DATA,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"]["base"] == "zeroconf_failed"
|
||||
|
||||
|
||||
async def test_flow_reauth(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Test Radarr config flow."""
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from aiopyarr import ArrException
|
||||
from aiopyarr import exceptions
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.radarr.const import DEFAULT_NAME, DOMAIN
|
||||
|
@ -115,7 +115,7 @@ async def test_wrong_app(hass: HomeAssistant) -> None:
|
|||
"""Test we show user form on wrong app."""
|
||||
with patch(
|
||||
"homeassistant.components.radarr.config_flow.RadarrClient.async_try_zeroconf",
|
||||
return_value="wrong_app",
|
||||
side_effect=exceptions.ArrWrongAppException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -125,14 +125,31 @@ async def test_wrong_app(hass: HomeAssistant) -> None:
|
|||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "wrong_app"}
|
||||
assert result["errors"]["base"] == "wrong_app"
|
||||
|
||||
|
||||
async def test_zero_conf_failure(hass: HomeAssistant) -> None:
|
||||
"""Test we show user form on api key retrieval failure."""
|
||||
with patch(
|
||||
"homeassistant.components.radarr.config_flow.RadarrClient.async_try_zeroconf",
|
||||
side_effect=exceptions.ArrZeroConfException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
data={CONF_URL: URL, CONF_VERIFY_SSL: False},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"]["base"] == "zeroconf_failed"
|
||||
|
||||
|
||||
async def test_unknown_error(hass: HomeAssistant) -> None:
|
||||
"""Test we show user form on unknown error."""
|
||||
with patch(
|
||||
"homeassistant.components.radarr.config_flow.RadarrClient.async_get_system_status",
|
||||
side_effect=ArrException,
|
||||
side_effect=exceptions.ArrException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
|
Loading…
Add table
Reference in a new issue