Use common strings for songpal config flow (#35517)

pull/35533/head
Xiaonan Shen 2020-05-11 20:48:41 -07:00 committed by GitHub
parent ea9c103fe1
commit 2748dcaaf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 10 deletions

View File

@ -64,7 +64,7 @@ class SongpalConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
): str, ): str,
} }
), ),
errors={"base": "connection"}, errors={"base": "cannot_connect"},
) )
self.conf = SongpalConfig(name, parsed_url.hostname, endpoint) self.conf = SongpalConfig(name, parsed_url.hostname, endpoint)
@ -139,7 +139,7 @@ class SongpalConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
name = interface_info.modelName name = interface_info.modelName
except SongpalException as ex: except SongpalException as ex:
_LOGGER.error("Import from yaml configuration failed: %s", 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) self.conf = SongpalConfig(name, parsed_url.hostname, endpoint)

View File

@ -5,19 +5,17 @@
"user": { "user": {
"data": { "data": {
"endpoint": "Endpoint" "endpoint": "Endpoint"
}, }
"title": "Sony Songpal"
}, },
"init": { "init": {
"description": "Do you want to set up {name} ({host})?", "description": "Do you want to set up {name} ({host})?"
"title": "Sony Songpal"
} }
}, },
"error": { "error": {
"connection": "Connection error: please check your endpoint" "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
}, },
"abort": { "abort": {
"already_configured": "Device already configured", "already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"not_songpal_device": "Not a Songpal device" "not_songpal_device": "Not a Songpal device"
} }
} }

View File

@ -207,7 +207,7 @@ async def test_user_invalid(hass):
) )
assert result["type"] == RESULT_TYPE_FORM assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "user" 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_supported_methods.assert_called_once()
mocked_device.get_interface_information.assert_not_called() 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 DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA
) )
assert result["type"] == RESULT_TYPE_ABORT 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_supported_methods.assert_called_once()
mocked_device.get_interface_information.assert_not_called() mocked_device.get_interface_information.assert_not_called()