Skip to content

Commit

Permalink
Use common strings in twentemilieu config flow (home-assistant#41647)
Browse files Browse the repository at this point in the history
  • Loading branch information
scheric authored Oct 11, 2020
1 parent 1c4512b commit 1f4fe62
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/twentemilieu/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def async_step_user(self, user_input=None):
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"
Expand All @@ -71,7 +71,7 @@ async def async_step_user(self, user_input=None):
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,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/twentemilieu/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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%]" }
}
}
4 changes: 2 additions & 2 deletions tests/components/twentemilieu/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 1f4fe62

Please sign in to comment.