From 33e69fe4bf2236aa5e6f507420a4174017b4c90b Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 6 Oct 2020 15:54:18 +0100 Subject: [PATCH] Update axis to use common strings (#41164) * Update axis to use common strings * Update common str device_unavailable to cannot_connect Co-authored-by: Robert Svensson --- homeassistant/components/axis/config_flow.py | 4 ++-- homeassistant/components/axis/strings.json | 8 ++++---- tests/components/axis/test_config_flow.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py index 5b300fe323b..ea1db54855b 100644 --- a/homeassistant/components/axis/config_flow.py +++ b/homeassistant/components/axis/config_flow.py @@ -94,10 +94,10 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): return await self._create_entry() except AuthenticationRequired: - errors["base"] = "faulty_credentials" + errors["base"] = "invalid_auth" except CannotConnect: - errors["base"] = "device_unavailable" + errors["base"] = "cannot_connect" data = self.discovery_schema or { vol.Required(CONF_HOST): str, diff --git a/homeassistant/components/axis/strings.json b/homeassistant/components/axis/strings.json index b98f9fe7ad1..046b7fee475 100644 --- a/homeassistant/components/axis/strings.json +++ b/homeassistant/components/axis/strings.json @@ -13,13 +13,13 @@ } }, "error": { - "already_configured": "Device is already configured", + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", "already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]", - "device_unavailable": "Device is not available", - "faulty_credentials": "Bad user credentials" + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", + "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]" }, "abort": { - "already_configured": "Device is already configured", + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", "link_local_address": "Link local addresses are not supported", "not_axis_device": "Discovered device not an Axis device" } diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index e5a32c4489a..5d9a794e3f6 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -139,11 +139,11 @@ async def test_flow_fails_faulty_credentials(hass): }, ) - assert result["errors"] == {"base": "faulty_credentials"} + assert result["errors"] == {"base": "invalid_auth"} -async def test_flow_fails_device_unavailable(hass): - """Test that config flow fails on device unavailable.""" +async def test_flow_fails_cannot_connect(hass): + """Test that config flow fails on cannot connect.""" result = await hass.config_entries.flow.async_init( AXIS_DOMAIN, context={"source": "user"} ) @@ -165,7 +165,7 @@ async def test_flow_fails_device_unavailable(hass): }, ) - assert result["errors"] == {"base": "device_unavailable"} + assert result["errors"] == {"base": "cannot_connect"} async def test_flow_create_entry_multiple_existing_entries_of_same_model(hass):