Use common strings in twentemilieu config flow (#41647)

This commit is contained in:
scheric 2020-10-11 14:54:08 +02:00 committed by GitHub
parent 1c4512bc40
commit 1f4fe62380
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -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,

View file

@ -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%]" }
}
}

View file

@ -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):