Use reference strings in Tesla (#41238)

pull/41306/head
SNoof85 2020-10-05 14:32:09 +02:00 committed by GitHub
parent 5745e64cab
commit f679acd3fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 11 deletions

View File

@ -62,7 +62,7 @@ class TeslaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(
step_id="user",
data_schema=DATA_SCHEMA,
errors={CONF_USERNAME: "identifier_exists"},
errors={CONF_USERNAME: "already_configured_account"},
description_placeholders={},
)
@ -72,14 +72,14 @@ class TeslaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(
step_id="user",
data_schema=DATA_SCHEMA,
errors={"base": "connection_error"},
errors={"base": "cannot_connect"},
description_placeholders={},
)
except InvalidAuth:
return self.async_show_form(
step_id="user",
data_schema=DATA_SCHEMA,
errors={"base": "invalid_credentials"},
errors={"base": "invalid_auth"},
description_placeholders={},
)
return self.async_create_entry(title=user_input[CONF_USERNAME], data=info)

View File

@ -1,10 +1,9 @@
{
"config": {
"error": {
"connection_error": "Error connecting; check network and retry",
"identifier_exists": "Email already registered",
"invalid_credentials": "Invalid credentials",
"unknown_error": "Unknown error, please report log info"
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"already_configured_account": "[%key:common::config_flow::abort::already_configured_account%]",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]"
},
"step": {
"user": {
@ -27,4 +26,4 @@
}
}
}
}
}

View File

@ -70,7 +70,7 @@ async def test_form_invalid_auth(hass):
)
assert result2["type"] == "form"
assert result2["errors"] == {"base": "invalid_credentials"}
assert result2["errors"] == {"base": "invalid_auth"}
async def test_form_cannot_connect(hass):
@ -89,7 +89,7 @@ async def test_form_cannot_connect(hass):
)
assert result2["type"] == "form"
assert result2["errors"] == {"base": "connection_error"}
assert result2["errors"] == {"base": "cannot_connect"}
async def test_form_repeat_identifier(hass):
@ -110,7 +110,7 @@ async def test_form_repeat_identifier(hass):
)
assert result2["type"] == "form"
assert result2["errors"] == {CONF_USERNAME: "identifier_exists"}
assert result2["errors"] == {CONF_USERNAME: "already_configured_account"}
async def test_import(hass):