From 1f4fe62380602a9fb8660d63456b5b817b4cf356 Mon Sep 17 00:00:00 2001 From: scheric <38077357+scheric@users.noreply.github.com> Date: Sun, 11 Oct 2020 14:54:08 +0200 Subject: [PATCH] Use common strings in twentemilieu config flow (#41647) --- homeassistant/components/twentemilieu/config_flow.py | 4 ++-- homeassistant/components/twentemilieu/strings.json | 4 ++-- tests/components/twentemilieu/test_config_flow.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/twentemilieu/config_flow.py b/homeassistant/components/twentemilieu/config_flow.py index 8c2180ca0dd..071f035f4f9 100644 --- a/homeassistant/components/twentemilieu/config_flow.py +++ b/homeassistant/components/twentemilieu/config_flow.py @@ -62,7 +62,7 @@ class TwenteMilieuFlowHandler(ConfigFlow): try: unique_id = await twentemilieu.unique_id() except TwenteMilieuConnectionError: - errors["base"] = "connection_error" + errors["base"] = "cannot_connect" return await self._show_setup_form(errors) except TwenteMilieuAddressError: errors["base"] = "invalid_address" @@ -71,7 +71,7 @@ class TwenteMilieuFlowHandler(ConfigFlow): entries = self._async_current_entries() for entry in entries: if entry.data[CONF_ID] == unique_id: - return self.async_abort(reason="address_already_set_up") + return self.async_abort(reason="already_configured") return self.async_create_entry( title=unique_id, diff --git a/homeassistant/components/twentemilieu/strings.json b/homeassistant/components/twentemilieu/strings.json index 75005e7cb37..369484a6392 100644 --- a/homeassistant/components/twentemilieu/strings.json +++ b/homeassistant/components/twentemilieu/strings.json @@ -12,9 +12,9 @@ } }, "error": { - "connection_error": "Failed to connect.", + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", "invalid_address": "Address not found in Twente Milieu service area." }, - "abort": { "address_exists": "Address already set up." } + "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_location%]" } } } diff --git a/tests/components/twentemilieu/test_config_flow.py b/tests/components/twentemilieu/test_config_flow.py index d176c6b1ee4..ec3edf73f29 100644 --- a/tests/components/twentemilieu/test_config_flow.py +++ b/tests/components/twentemilieu/test_config_flow.py @@ -43,7 +43,7 @@ async def test_connection_error(hass, aioclient_mock): assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user" - assert result["errors"] == {"base": "connection_error"} + assert result["errors"] == {"base": "cannot_connect"} async def test_invalid_address(hass, aioclient_mock): @@ -80,7 +80,7 @@ async def test_address_already_set_up(hass, aioclient_mock): result = await flow.async_step_user(user_input=FIXTURE_USER_INPUT) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "address_already_set_up" + assert result["reason"] == "already_configured" async def test_full_flow_implementation(hass, aioclient_mock):