Skip to content

Commit

Permalink
Use of reference strings in Transmission config flow (home-assistant#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pigotka authored Oct 6, 2020
1 parent 14273e9 commit ed9a408
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions homeassistant/components/transmission/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ async def async_step_user(self, user_input=None):
if entry.data[CONF_NAME] == user_input[CONF_NAME]:
errors[CONF_NAME] = "name_exists"
break

try:
await get_api(self.hass, user_input)

except AuthenticationError:
errors[CONF_USERNAME] = "wrong_credentials"
errors[CONF_PASSWORD] = "wrong_credentials"
errors[CONF_USERNAME] = "invalid_auth"
errors[CONF_PASSWORD] = "invalid_auth"
except (CannotConnect, UnknownError):
errors["base"] = "cannot_connect"

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/transmission/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
}
},
"error": {
"name_exists": "Name already exists",
"wrong_credentials": "Wrong username or password",
"cannot_connect": "Unable to Connect to host"
"name_exists": "[%key:common::config_flow::data::name%] already exists",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"abort": {
"already_configured": "Host is already configured."
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"options": {
Expand Down
4 changes: 2 additions & 2 deletions tests/components/transmission/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ async def test_error_on_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",
}


Expand Down

0 comments on commit ed9a408

Please sign in to comment.