Manager wrong country selection in Alexa Devices (#147914)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Simone Chemelli 2025-07-02 09:02:53 +03:00 committed by GitHub
parent 48f9a12cca
commit 77dcba0984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,7 @@ from collections.abc import Mapping
from typing import Any
from aioamazondevices.api import AmazonEchoApi
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
@ -57,6 +57,8 @@ class AmazonDevicesConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except CannotAuthenticate:
errors["base"] = "invalid_auth"
except WrongCountry:
errors["base"] = "wrong_country"
else:
await self.async_set_unique_id(data["customer_info"]["user_id"])
self._abort_if_unique_id_configured()

View File

@ -44,6 +44,7 @@
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"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%]"
}
},

View File

@ -2,7 +2,7 @@
from unittest.mock import AsyncMock
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
import pytest
from homeassistant.components.alexa_devices.const import CONF_LOGIN_DATA, DOMAIN
@ -57,6 +57,7 @@ async def test_full_flow(
[
(CannotConnect, "cannot_connect"),
(CannotAuthenticate, "invalid_auth"),
(WrongCountry, "wrong_country"),
],
)
async def test_flow_errors(