Skip to content

Commit 08a850c

Browse files
authored
Fix exception countries migration for Alexa Devices (home-assistant#151292)
1 parent 1297809 commit 08a850c

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

homeassistant/components/alexa_devices/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: AmazonConfigEntry) ->
4848
)
4949

5050
# Convert country in domain
51-
country = entry.data[CONF_COUNTRY]
51+
country = entry.data[CONF_COUNTRY].lower()
5252
domain = COUNTRY_DOMAINS.get(country, country)
5353

5454
# Add site to login data

homeassistant/components/alexa_devices/const.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
DOMAIN = "alexa_devices"
88
CONF_LOGIN_DATA = "login_data"
99

10-
DEFAULT_DOMAIN = {"domain": "com"}
10+
DEFAULT_DOMAIN = "com"
1111
COUNTRY_DOMAINS = {
1212
"ar": DEFAULT_DOMAIN,
1313
"at": DEFAULT_DOMAIN,
14-
"au": {"domain": "com.au"},
15-
"be": {"domain": "com.be"},
14+
"au": "com.au",
15+
"be": "com.be",
1616
"br": DEFAULT_DOMAIN,
17-
"gb": {"domain": "co.uk"},
17+
"gb": "co.uk",
1818
"il": DEFAULT_DOMAIN,
19-
"jp": {"domain": "co.jp"},
20-
"mx": {"domain": "com.mx"},
19+
"jp": "co.jp",
20+
"mx": "com.mx",
2121
"no": DEFAULT_DOMAIN,
22-
"nz": {"domain": "com.au"},
22+
"nz": "com.au",
2323
"pl": DEFAULT_DOMAIN,
24-
"tr": {"domain": "com.tr"},
24+
"tr": "com.tr",
2525
"us": DEFAULT_DOMAIN,
26-
"za": {"domain": "co.za"},
26+
"za": "co.za",
2727
}

tests/components/alexa_devices/const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Alexa Devices tests const."""
22

33
TEST_CODE = "023123"
4-
TEST_COUNTRY = "IT"
54
TEST_PASSWORD = "fake_password"
65
TEST_SERIAL_NUMBER = "echo_test_serial_number"
76
TEST_USERNAME = "[email protected]"

tests/components/alexa_devices/test_init.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from homeassistant.helpers import device_registry as dr
1212

1313
from . import setup_integration
14-
from .const import TEST_COUNTRY, TEST_PASSWORD, TEST_SERIAL_NUMBER, TEST_USERNAME
14+
from .const import TEST_PASSWORD, TEST_SERIAL_NUMBER, TEST_USERNAME
1515

1616
from tests.common import MockConfigEntry
1717

@@ -42,7 +42,7 @@ async def test_migrate_entry(
4242
domain=DOMAIN,
4343
title="Amazon Test Account",
4444
data={
45-
CONF_COUNTRY: TEST_COUNTRY,
45+
CONF_COUNTRY: "US", # country should be in COUNTRY_DOMAINS exceptions
4646
CONF_USERNAME: TEST_USERNAME,
4747
CONF_PASSWORD: TEST_PASSWORD,
4848
CONF_LOGIN_DATA: {"session": "test-session"},
@@ -58,7 +58,4 @@ async def test_migrate_entry(
5858
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
5959
assert config_entry.state is ConfigEntryState.LOADED
6060
assert config_entry.minor_version == 2
61-
assert (
62-
config_entry.data[CONF_LOGIN_DATA]["site"]
63-
== f"https://www.amazon.{TEST_COUNTRY}"
64-
)
61+
assert config_entry.data[CONF_LOGIN_DATA]["site"] == "https://www.amazon.com"

0 commit comments

Comments
 (0)