mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use common strings in twentemilieu config flow (#41647)
This commit is contained in:
parent
1c4512bc40
commit
1f4fe62380
@ -62,7 +62,7 @@ class TwenteMilieuFlowHandler(ConfigFlow):
|
|||||||
try:
|
try:
|
||||||
unique_id = await twentemilieu.unique_id()
|
unique_id = await twentemilieu.unique_id()
|
||||||
except TwenteMilieuConnectionError:
|
except TwenteMilieuConnectionError:
|
||||||
errors["base"] = "connection_error"
|
errors["base"] = "cannot_connect"
|
||||||
return await self._show_setup_form(errors)
|
return await self._show_setup_form(errors)
|
||||||
except TwenteMilieuAddressError:
|
except TwenteMilieuAddressError:
|
||||||
errors["base"] = "invalid_address"
|
errors["base"] = "invalid_address"
|
||||||
@ -71,7 +71,7 @@ class TwenteMilieuFlowHandler(ConfigFlow):
|
|||||||
entries = self._async_current_entries()
|
entries = self._async_current_entries()
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
if entry.data[CONF_ID] == unique_id:
|
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(
|
return self.async_create_entry(
|
||||||
title=unique_id,
|
title=unique_id,
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"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."
|
"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%]" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ async def test_connection_error(hass, aioclient_mock):
|
|||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
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):
|
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)
|
result = await flow.async_step_user(user_input=FIXTURE_USER_INPUT)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
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):
|
async def test_full_flow_implementation(hass, aioclient_mock):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user