From 2748dcaaf1bd39216ebb94c1350caeeaa241a770 Mon Sep 17 00:00:00 2001 From: Xiaonan Shen Date: Mon, 11 May 2020 20:48:41 -0700 Subject: [PATCH] Use common strings for songpal config flow (#35517) --- homeassistant/components/songpal/config_flow.py | 4 ++-- homeassistant/components/songpal/strings.json | 10 ++++------ tests/components/songpal/test_config_flow.py | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/songpal/config_flow.py b/homeassistant/components/songpal/config_flow.py index 206cfce575d..96e1e7ed7df 100644 --- a/homeassistant/components/songpal/config_flow.py +++ b/homeassistant/components/songpal/config_flow.py @@ -64,7 +64,7 @@ class SongpalConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ): str, } ), - errors={"base": "connection"}, + errors={"base": "cannot_connect"}, ) self.conf = SongpalConfig(name, parsed_url.hostname, endpoint) @@ -139,7 +139,7 @@ class SongpalConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): name = interface_info.modelName except SongpalException as ex: _LOGGER.error("Import from yaml configuration failed: %s", ex) - return self.async_abort(reason="connection") + return self.async_abort(reason="cannot_connect") self.conf = SongpalConfig(name, parsed_url.hostname, endpoint) diff --git a/homeassistant/components/songpal/strings.json b/homeassistant/components/songpal/strings.json index 7948e99af29..65c42ddef6a 100644 --- a/homeassistant/components/songpal/strings.json +++ b/homeassistant/components/songpal/strings.json @@ -5,19 +5,17 @@ "user": { "data": { "endpoint": "Endpoint" - }, - "title": "Sony Songpal" + } }, "init": { - "description": "Do you want to set up {name} ({host})?", - "title": "Sony Songpal" + "description": "Do you want to set up {name} ({host})?" } }, "error": { - "connection": "Connection error: please check your endpoint" + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" }, "abort": { - "already_configured": "Device already configured", + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", "not_songpal_device": "Not a Songpal device" } } diff --git a/tests/components/songpal/test_config_flow.py b/tests/components/songpal/test_config_flow.py index baf0c9ef0fa..e837ed0e032 100644 --- a/tests/components/songpal/test_config_flow.py +++ b/tests/components/songpal/test_config_flow.py @@ -207,7 +207,7 @@ async def test_user_invalid(hass): ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" - assert result["errors"] == {"base": "connection"} + assert result["errors"] == {"base": "cannot_connect"} mocked_device.get_supported_methods.assert_called_once() mocked_device.get_interface_information.assert_not_called() @@ -223,7 +223,7 @@ async def test_import_invalid(hass): DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA ) assert result["type"] == RESULT_TYPE_ABORT - assert result["reason"] == "connection" + assert result["reason"] == "cannot_connect" mocked_device.get_supported_methods.assert_called_once() mocked_device.get_interface_information.assert_not_called()