Use common strings in Azure DevOps config flow (#41974)
This commit is contained in:
parent
74a1b75919
commit
87deb2344c
3 changed files with 9 additions and 9 deletions
|
@ -60,14 +60,14 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
if self._pat is not None:
|
if self._pat is not None:
|
||||||
await client.authorize(self._pat, self._organization)
|
await client.authorize(self._pat, self._organization)
|
||||||
if not client.authorized:
|
if not client.authorized:
|
||||||
errors["base"] = "authorization_error"
|
errors["base"] = "invalid_auth"
|
||||||
return errors
|
return errors
|
||||||
project_info = await client.get_project(self._organization, self._project)
|
project_info = await client.get_project(self._organization, self._project)
|
||||||
if project_info is None:
|
if project_info is None:
|
||||||
errors["base"] = "project_error"
|
errors["base"] = "project_error"
|
||||||
return errors
|
return errors
|
||||||
except aiohttp.ClientError:
|
except aiohttp.ClientError:
|
||||||
errors["base"] = "connection_error"
|
errors["base"] = "cannot_connect"
|
||||||
return errors
|
return errors
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
"config": {
|
"config": {
|
||||||
"flow_title": "Azure DevOps: {project_url}",
|
"flow_title": "Azure DevOps: {project_url}",
|
||||||
"error": {
|
"error": {
|
||||||
"authorization_error": "Authorization error. Check you have access to the project and have the correct credentials.",
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
"connection_error": "Could not connect to Azure DevOps.",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
"project_error": "Could not get project info."
|
"project_error": "Could not get project info."
|
||||||
},
|
},
|
||||||
"step": {
|
"step": {
|
||||||
|
|
|
@ -51,7 +51,7 @@ async def test_authorization_error(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result2["step_id"] == "user"
|
assert result2["step_id"] == "user"
|
||||||
assert result2["errors"] == {"base": "authorization_error"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
||||||
|
@ -75,7 +75,7 @@ async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result2["step_id"] == "reauth"
|
assert result2["step_id"] == "reauth"
|
||||||
assert result2["errors"] == {"base": "authorization_error"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
async def test_connection_error(hass: HomeAssistant) -> None:
|
async def test_connection_error(hass: HomeAssistant) -> None:
|
||||||
|
@ -99,7 +99,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result2["step_id"] == "user"
|
assert result2["step_id"] == "user"
|
||||||
assert result2["errors"] == {"base": "connection_error"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
||||||
|
@ -123,7 +123,7 @@ async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result2["step_id"] == "reauth"
|
assert result2["step_id"] == "reauth"
|
||||||
assert result2["errors"] == {"base": "connection_error"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
async def test_project_error(hass: HomeAssistant) -> None:
|
async def test_project_error(hass: HomeAssistant) -> None:
|
||||||
|
@ -201,7 +201,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "reauth"
|
assert result["step_id"] == "reauth"
|
||||||
assert result["errors"] == {"base": "authorization_error"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
|
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
|
||||||
|
|
Loading…
Add table
Reference in a new issue