mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Manager wrong country selection in Alexa Devices (#147914)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
48f9a12cca
commit
77dcba0984
@ -6,7 +6,7 @@ from collections.abc import Mapping
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aioamazondevices.api import AmazonEchoApi
|
from aioamazondevices.api import AmazonEchoApi
|
||||||
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect
|
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
@ -57,6 +57,8 @@ class AmazonDevicesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except CannotAuthenticate:
|
except CannotAuthenticate:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
except WrongCountry:
|
||||||
|
errors["base"] = "wrong_country"
|
||||||
else:
|
else:
|
||||||
await self.async_set_unique_id(data["customer_info"]["user_id"])
|
await self.async_set_unique_id(data["customer_info"]["user_id"])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
|
"wrong_country": "Wrong country selected. Please select the country where your Amazon account is registered.",
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect
|
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.alexa_devices.const import CONF_LOGIN_DATA, DOMAIN
|
from homeassistant.components.alexa_devices.const import CONF_LOGIN_DATA, DOMAIN
|
||||||
@ -57,6 +57,7 @@ async def test_full_flow(
|
|||||||
[
|
[
|
||||||
(CannotConnect, "cannot_connect"),
|
(CannotConnect, "cannot_connect"),
|
||||||
(CannotAuthenticate, "invalid_auth"),
|
(CannotAuthenticate, "invalid_auth"),
|
||||||
|
(WrongCountry, "wrong_country"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_flow_errors(
|
async def test_flow_errors(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user