From 1b864aeccc1af2215048ef210f83be638a684607 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Thu, 1 Oct 2020 12:56:55 +0200 Subject: [PATCH] Use common strings in adguard config flow (#40942) --- homeassistant/components/adguard/config_flow.py | 4 ++-- homeassistant/components/adguard/strings.json | 6 ++++-- tests/components/adguard/test_config_flow.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/adguard/config_flow.py b/homeassistant/components/adguard/config_flow.py index a0ace623862..c799c4a7135 100644 --- a/homeassistant/components/adguard/config_flow.py +++ b/homeassistant/components/adguard/config_flow.py @@ -80,7 +80,7 @@ class AdGuardHomeFlowHandler(ConfigFlow): try: await adguard.version() except AdGuardHomeConnectionError: - errors["base"] = "connection_error" + errors["base"] = "cannot_connect" return await self._show_setup_form(errors) return self.async_create_entry( @@ -152,7 +152,7 @@ class AdGuardHomeFlowHandler(ConfigFlow): try: await adguard.version() except AdGuardHomeConnectionError: - errors["base"] = "connection_error" + errors["base"] = "cannot_connect" return await self._show_hassio_form(errors) return self.async_create_entry( diff --git a/homeassistant/components/adguard/strings.json b/homeassistant/components/adguard/strings.json index f010f9e2ade..2658f7344d4 100644 --- a/homeassistant/components/adguard/strings.json +++ b/homeassistant/components/adguard/strings.json @@ -17,10 +17,12 @@ "description": "Do you want to configure Home Assistant to connect to the AdGuard Home provided by the Hass.io add-on: {addon}?" } }, - "error": { "connection_error": "Failed to connect." }, + "error": { + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" + }, "abort": { "existing_instance_updated": "Updated existing configuration.", - "single_instance_allowed": "Only a single configuration of AdGuard Home is allowed." + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" } } } diff --git a/tests/components/adguard/test_config_flow.py b/tests/components/adguard/test_config_flow.py index e773768ebe6..36263335dac 100644 --- a/tests/components/adguard/test_config_flow.py +++ b/tests/components/adguard/test_config_flow.py @@ -53,7 +53,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_full_flow_implementation(hass, aioclient_mock): @@ -235,4 +235,4 @@ async def test_hassio_connection_error(hass, aioclient_mock): assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "hassio_confirm" - assert result["errors"] == {"base": "connection_error"} + assert result["errors"] == {"base": "cannot_connect"}