mirror of
https://github.com/home-assistant/core.git
synced 2025-04-22 16:27:56 +00:00
Use common strings for Mikrotik config flow (#41110)
This commit is contained in:
parent
cb8d7fe575
commit
3208670b61
@ -43,7 +43,7 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if user_input is not None:
|
||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||
if entry.data[CONF_HOST] == user_input[CONF_HOST]:
|
||||
return self.async_abort(reason="already_configured")
|
||||
return self.async_abort(reason="already_configured_device")
|
||||
if entry.data[CONF_NAME] == user_input[CONF_NAME]:
|
||||
errors[CONF_NAME] = "name_exists"
|
||||
break
|
||||
@ -53,8 +53,8 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
except CannotConnect:
|
||||
errors["base"] = "cannot_connect"
|
||||
except LoginError:
|
||||
errors[CONF_USERNAME] = "wrong_credentials"
|
||||
errors[CONF_PASSWORD] = "wrong_credentials"
|
||||
errors[CONF_USERNAME] = "invalid_auth"
|
||||
errors[CONF_PASSWORD] = "invalid_auth"
|
||||
|
||||
if not errors:
|
||||
return self.async_create_entry(
|
||||
|
@ -15,11 +15,11 @@
|
||||
},
|
||||
"error": {
|
||||
"name_exists": "Name exists",
|
||||
"cannot_connect": "Connection Unsuccessful",
|
||||
"wrong_credentials": "Wrong Credentials"
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "Mikrotik is already configured"
|
||||
"already_configured_device": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
@ -33,4 +33,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ async def test_host_already_configured(hass, auth_error):
|
||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "already_configured"
|
||||
assert result["reason"] == "already_configured_device"
|
||||
|
||||
|
||||
async def test_name_exists(hass, api):
|
||||
@ -203,6 +203,6 @@ async def test_wrong_credentials(hass, auth_error):
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["errors"] == {
|
||||
CONF_USERNAME: "wrong_credentials",
|
||||
CONF_PASSWORD: "wrong_credentials",
|
||||
CONF_USERNAME: "invalid_auth",
|
||||
CONF_PASSWORD: "invalid_auth",
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user