Address late review of AsusWRT unique id PR (#71281)

This commit is contained in:
ollo69 2022-05-04 11:39:55 +02:00 committed by GitHub
parent 9e2f0b3af1
commit ee8eac10c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -149,10 +149,10 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN):
) -> FlowResult: ) -> FlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
# if exist one entry without unique ID, we abort config flow # if there's one entry without unique ID, we abort config flow
for unique_id in self._async_current_ids(): for unique_id in self._async_current_ids():
if unique_id is None: if unique_id is None:
return self.async_abort(reason="not_unique_id_exist") return self.async_abort(reason="no_unique_id")
if user_input is None: if user_input is None:
return self._show_setup_form(user_input) return self._show_setup_form(user_input)
@ -188,7 +188,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN):
return self.async_abort(reason="invalid_unique_id") return self.async_abort(reason="invalid_unique_id")
else: else:
_LOGGER.warning( _LOGGER.warning(
"This device do not provide a valid Unique ID." "This device does not provide a valid Unique ID."
" Configuration of multiple instance will not be possible" " Configuration of multiple instance will not be possible"
) )

View File

@ -26,7 +26,7 @@
}, },
"abort": { "abort": {
"invalid_unique_id": "Impossible to determine a valid unique id for the device", "invalid_unique_id": "Impossible to determine a valid unique id for the device",
"not_unique_id_exist": "A device without a valid unique id is already configured. Configuration of multiple instance is not possible" "no_unique_id": "A device without a valid unique id is already configured. Configuration of multiple instance is not possible"
} }
}, },
"options": { "options": {

View File

@ -2,8 +2,7 @@
"config": { "config": {
"abort": { "abort": {
"invalid_unique_id": "Impossible to determine a valid unique id for the device", "invalid_unique_id": "Impossible to determine a valid unique id for the device",
"not_unique_id_exist": "A device without a valid unique id is already configured. Configuration of multiple instance is not possible", "no_unique_id": "A device without a valid unique id is already configured. Configuration of multiple instance is not possible"
"single_instance_allowed": "Already configured. Only a single configuration possible."
}, },
"error": { "error": {
"cannot_connect": "Failed to connect", "cannot_connect": "Failed to connect",
@ -44,4 +43,4 @@
} }
} }
} }
} }

View File

@ -169,7 +169,7 @@ async def test_abort_if_not_unique_id_setup(hass):
data=CONFIG_DATA, data=CONFIG_DATA,
) )
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "not_unique_id_exist" assert result["reason"] == "no_unique_id"
@pytest.mark.usefixtures("connect") @pytest.mark.usefixtures("connect")