Fix error message strings for Todoist configuration flow (#102968)

* Fix error message strings for Todoist configuration flow

* Update error code in test
This commit is contained in:
Allen Porter 2023-10-28 12:02:42 -07:00 committed by GitHub
parent fb5d058885
commit efc9f845db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -44,7 +44,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
await api.get_tasks() await api.get_tasks()
except HTTPError as err: except HTTPError as err:
if err.response.status_code == HTTPStatus.UNAUTHORIZED: if err.response.status_code == HTTPStatus.UNAUTHORIZED:
errors["base"] = "invalid_access_token" errors["base"] = "invalid_api_key"
else: else:
errors["base"] = "cannot_connect" errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except

View File

@ -9,10 +9,12 @@
} }
}, },
"error": { "error": {
"invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]" "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]",
"unknown": "[%key:common::config_flow::error::unknown%]"
}, },
"abort": { "abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]" "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
}, },
"create_entry": { "create_entry": {
"default": "[%key:common::config_flow::create_entry::authenticated%]" "default": "[%key:common::config_flow::create_entry::authenticated%]"

View File

@ -69,7 +69,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
) )
assert result2.get("type") == FlowResultType.FORM assert result2.get("type") == FlowResultType.FORM
assert result2.get("errors") == {"base": "invalid_access_token"} assert result2.get("errors") == {"base": "invalid_api_key"}
@pytest.mark.parametrize("todoist_api_status", [HTTPStatus.INTERNAL_SERVER_ERROR]) @pytest.mark.parametrize("todoist_api_status", [HTTPStatus.INTERNAL_SERVER_ERROR])