Add unknown_authorize_url_generation to base strings for config flows (#42484)

This commit is contained in:
springstan 2020-11-24 18:00:16 +01:00 committed by GitHub
parent 3dd14e05e3
commit 5a892e8fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 14 additions and 13 deletions

View File

@ -177,7 +177,7 @@ class NestFlowHandler(
return self.async_abort(reason="authorize_url_timeout") return self.async_abort(reason="authorize_url_timeout")
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected error generating auth url") _LOGGER.exception("Unexpected error generating auth url")
return self.async_abort(reason="authorize_url_fail") return self.async_abort(reason="unknown_authorize_url_generation")
return self.async_show_form( return self.async_show_form(
step_id="link", step_id="link",

View File

@ -25,7 +25,7 @@
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]",
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]", "missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]", "authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
"authorize_url_fail": "Unknown error generating an authorize url.", "unknown_authorize_url_generation": "[%key:common::config_flow::abort::unknown_authorize_url_generation%]",
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]" "no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]"
}, },
"create_entry": { "create_entry": {

View File

@ -101,7 +101,7 @@ class PointFlowHandler(config_entries.ConfigFlow):
return self.async_abort(reason="authorize_url_timeout") return self.async_abort(reason="authorize_url_timeout")
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected error generating auth url") _LOGGER.exception("Unexpected error generating auth url")
return self.async_abort(reason="authorize_url_fail") return self.async_abort(reason="unknown_authorize_url_generation")
return self.async_show_form( return self.async_show_form(
step_id="auth", step_id="auth",
description_placeholders={"authorization_url": url}, description_placeholders={"authorization_url": url},

View File

@ -23,7 +23,7 @@
"external_setup": "Point successfully configured from another flow.", "external_setup": "Point successfully configured from another flow.",
"no_flows": "[%key:common::config_flow::abort::oauth2_missing_configuration%]", "no_flows": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]", "authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
"authorize_url_fail": "Unknown error generating an authorize url." "unknown_authorize_url_generation": "[%key:common::config_flow::abort::unknown_authorize_url_generation%]"
} }
} }
} }

View File

@ -97,12 +97,12 @@ class FlowHandler(config_entries.ConfigFlow):
with async_timeout.timeout(10): with async_timeout.timeout(10):
auth_url = await self.hass.async_add_executor_job(self._get_auth_url) auth_url = await self.hass.async_add_executor_job(self._get_auth_url)
if not auth_url: if not auth_url:
return self.async_abort(reason="authorize_url_fail") return self.async_abort(reason="unknown_authorize_url_generation")
except asyncio.TimeoutError: except asyncio.TimeoutError:
return self.async_abort(reason="authorize_url_timeout") return self.async_abort(reason="authorize_url_timeout")
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected error generating auth url") _LOGGER.exception("Unexpected error generating auth url")
return self.async_abort(reason="authorize_url_fail") return self.async_abort(reason="unknown_authorize_url_generation")
_LOGGER.debug("Got authorization URL %s", auth_url) _LOGGER.debug("Got authorization URL %s", auth_url)
return self.async_show_form( return self.async_show_form(

View File

@ -2,7 +2,7 @@
"config": { "config": {
"abort": { "abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]", "already_configured": "[%key:common::config_flow::abort::already_configured_service%]",
"authorize_url_fail": "Unknown error generating an authorize url.", "unknown_authorize_url_generation": "[%key:common::config_flow::abort::unknown_authorize_url_generation%]",
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]", "authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
"unknown": "[%key:common::config_flow::error::unknown%]" "unknown": "[%key:common::config_flow::error::unknown%]"
}, },

View File

@ -14,7 +14,7 @@
}, },
"abort": { "abort": {
"already_configured": "The selected agreement is already configured.", "already_configured": "The selected agreement is already configured.",
"authorize_url_fail": "Unknown error generating an authorize url.", "unknown_authorize_url_generation": "[%key:common::config_flow::abort::unknown_authorize_url_generation%]",
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]", "authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]", "missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
"no_agreements": "This account has no Toon displays.", "no_agreements": "This account has no Toon displays.",

View File

@ -70,7 +70,8 @@
"oauth2_missing_configuration": "The component is not configured. Please follow the documentation.", "oauth2_missing_configuration": "The component is not configured. Please follow the documentation.",
"oauth2_authorize_url_timeout": "Timeout generating authorize URL.", "oauth2_authorize_url_timeout": "Timeout generating authorize URL.",
"oauth2_no_url_available": "No URL available. For information about this error, [check the help section]({docs_url})", "oauth2_no_url_available": "No URL available. For information about this error, [check the help section]({docs_url})",
"reauth_successful": "Re-authentication was successful" "reauth_successful": "Re-authentication was successful",
"unknown_authorize_url_generation": "Unknown error generating an authorize url."
} }
} }
} }

View File

@ -100,7 +100,7 @@ async def test_abort_if_exception_generating_auth_url(hass):
flow.hass = hass flow.hass = hass
result = await flow.async_step_init() result = await flow.async_step_init()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "authorize_url_fail" assert result["reason"] == "unknown_authorize_url_generation"
async def test_verify_code_timeout(hass): async def test_verify_code_timeout(hass):

View File

@ -141,7 +141,7 @@ async def test_abort_if_exception_generating_auth_url(hass):
result = await flow.async_step_user() result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "authorize_url_fail" assert result["reason"] == "unknown_authorize_url_generation"
async def test_abort_no_code(hass): async def test_abort_no_code(hass):

View File

@ -229,7 +229,7 @@ async def test_abort_no_auth_url(hass, mock_tellduslive):
result = await flow.async_step_user() result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "authorize_url_fail" assert result["reason"] == "unknown_authorize_url_generation"
async def test_abort_if_exception_generating_auth_url(hass, mock_tellduslive): async def test_abort_if_exception_generating_auth_url(hass, mock_tellduslive):
@ -238,7 +238,7 @@ async def test_abort_if_exception_generating_auth_url(hass, mock_tellduslive):
result = await flow.async_step_user() result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "authorize_url_fail" assert result["reason"] == "unknown_authorize_url_generation"
async def test_discovery_already_configured(hass, mock_tellduslive): async def test_discovery_already_configured(hass, mock_tellduslive):