Address late feedback in SFR Box config flow (#85037)

* Address late feedback in SFR Box config flow

* Adjust tests
pull/85052/head
epenet 2023-01-03 12:18:05 +01:00 committed by GitHub
parent fed8f905c8
commit 2a9526de17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 8 deletions

View File

@ -30,14 +30,11 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
box = SFRBox(ip=user_input[CONF_HOST], client=get_async_client(self.hass))
try:
box = SFRBox(
ip=user_input[CONF_HOST],
client=get_async_client(self.hass),
)
system_info = await box.system_get_info()
except SFRBoxError:
errors["base"] = "unknown"
errors["base"] = "cannot_connect"
else:
await self.async_set_unique_id(system_info.mac_addr)
self._abort_if_unique_id_configured()

View File

@ -8,7 +8,7 @@
}
},
"error": {
"unknown": "[%key:common::config_flow::error::unknown%]"
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"

View File

@ -4,7 +4,7 @@
"already_configured": "Device is already configured"
},
"error": {
"unknown": "Unexpected error"
"cannot_connect": "Failed to connect"
},
"step": {
"user": {

View File

@ -43,7 +43,7 @@ async def test_config_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock):
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["errors"] == {"base": "unknown"}
assert result["errors"] == {"base": "cannot_connect"}
system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN)))
with patch(