From 8b30b6b312acc6b79013aaef27a2336109e76b35 Mon Sep 17 00:00:00 2001 From: Jenny Date: Sat, 3 Oct 2020 13:11:03 +0100 Subject: [PATCH] Use reference strings for openweathermap (#41055) --- homeassistant/components/openweathermap/config_flow.py | 6 +++--- homeassistant/components/openweathermap/strings.json | 8 ++++---- tests/components/openweathermap/test_config_flow.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/openweathermap/config_flow.py b/homeassistant/components/openweathermap/config_flow.py index 5f960e52ecf..1a50b035db8 100644 --- a/homeassistant/components/openweathermap/config_flow.py +++ b/homeassistant/components/openweathermap/config_flow.py @@ -69,11 +69,11 @@ class OpenWeatherMapConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self.hass, user_input[CONF_API_KEY] ) if not api_online: - errors["base"] = "auth" + errors["base"] = "invalid_api_key" except UnauthorizedError: - errors["base"] = "auth" + errors["base"] = "invalid_api_key" except APICallError: - errors["base"] = "connection" + errors["base"] = "cannot_connect" if not errors: return self.async_create_entry( diff --git a/homeassistant/components/openweathermap/strings.json b/homeassistant/components/openweathermap/strings.json index 79462f6912b..15b5c0f4d57 100644 --- a/homeassistant/components/openweathermap/strings.json +++ b/homeassistant/components/openweathermap/strings.json @@ -1,16 +1,16 @@ { "config": { "abort": { - "already_configured": "OpenWeatherMap integration for these coordinates is already configured." + "already_configured": "[%key:common::config_flow::abort::already_configured_service%] for these coordinates." }, "error": { - "auth": "API key is not correct.", - "connection": "Can't connect to OWM API" + "invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]", + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" }, "step": { "user": { "data": { - "api_key": "OpenWeatherMap API key", + "api_key": "[%key:common::config_flow::data::api_key%]", "language": "Language", "latitude": "[%key:common::config_flow::data::latitude%]", "longitude": "[%key:common::config_flow::data::longitude%]", diff --git a/tests/components/openweathermap/test_config_flow.py b/tests/components/openweathermap/test_config_flow.py index 672e7358803..f5844df6bfe 100644 --- a/tests/components/openweathermap/test_config_flow.py +++ b/tests/components/openweathermap/test_config_flow.py @@ -166,7 +166,7 @@ async def test_form_invalid_api_key(hass): DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) - assert result["errors"] == {"base": "auth"} + assert result["errors"] == {"base": "invalid_api_key"} async def test_form_api_call_error(hass): @@ -182,7 +182,7 @@ async def test_form_api_call_error(hass): DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) - assert result["errors"] == {"base": "connection"} + assert result["errors"] == {"base": "cannot_connect"} async def test_form_api_offline(hass): @@ -197,7 +197,7 @@ async def test_form_api_offline(hass): DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) - assert result["errors"] == {"base": "auth"} + assert result["errors"] == {"base": "invalid_api_key"} def _create_mocked_owm(is_api_online: bool):