mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Use common strings in ambiclimate config flow (#41772)
* already_configured_account->already_configured * add authenticated string * oauth2_missing_...->missing_configuration
This commit is contained in:
parent
d6d17aa295
commit
22b360a10e
@ -53,20 +53,20 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow):
|
|||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(self, user_input=None):
|
||||||
"""Handle external yaml configuration."""
|
"""Handle external yaml configuration."""
|
||||||
if self.hass.config_entries.async_entries(DOMAIN):
|
if self.hass.config_entries.async_entries(DOMAIN):
|
||||||
return self.async_abort(reason="already_configured_account")
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
||||||
config = self.hass.data.get(DATA_AMBICLIMATE_IMPL, {})
|
config = self.hass.data.get(DATA_AMBICLIMATE_IMPL, {})
|
||||||
|
|
||||||
if not config:
|
if not config:
|
||||||
_LOGGER.debug("No config")
|
_LOGGER.debug("No config")
|
||||||
return self.async_abort(reason="oauth2_missing_configuration")
|
return self.async_abort(reason="missing_configuration")
|
||||||
|
|
||||||
return await self.async_step_auth()
|
return await self.async_step_auth()
|
||||||
|
|
||||||
async def async_step_auth(self, user_input=None):
|
async def async_step_auth(self, user_input=None):
|
||||||
"""Handle a flow start."""
|
"""Handle a flow start."""
|
||||||
if self.hass.config_entries.async_entries(DOMAIN):
|
if self.hass.config_entries.async_entries(DOMAIN):
|
||||||
return self.async_abort(reason="already_configured_account")
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow):
|
|||||||
async def async_step_code(self, code=None):
|
async def async_step_code(self, code=None):
|
||||||
"""Received code for authentication."""
|
"""Received code for authentication."""
|
||||||
if self.hass.config_entries.async_entries(DOMAIN):
|
if self.hass.config_entries.async_entries(DOMAIN):
|
||||||
return self.async_abort(reason="already_configured_account")
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
||||||
token_info = await self._get_token_info(code)
|
token_info = await self._get_token_info(code)
|
||||||
|
|
||||||
|
@ -7,15 +7,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"create_entry": {
|
"create_entry": {
|
||||||
"default": "Successfully authenticated with Ambiclimate"
|
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"no_token": "Not authenticated with Ambiclimate",
|
"no_token": "Not authenticated with Ambiclimate",
|
||||||
"follow_link": "Please follow the link and authenticate before pressing Submit"
|
"follow_link": "Please follow the link and authenticate before pressing Submit"
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured_account": "[%key:common::config_flow::abort::already_configured_account%]",
|
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
|
||||||
"oauth2_missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
|
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
|
||||||
"access_token": "Unknown error generating an access token."
|
"access_token": "Unknown error generating an access token."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ async def test_abort_if_no_implementation_registered(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"] == "oauth2_missing_configuration"
|
assert result["reason"] == "missing_configuration"
|
||||||
|
|
||||||
|
|
||||||
async def test_abort_if_already_setup(hass):
|
async def test_abort_if_already_setup(hass):
|
||||||
@ -40,12 +40,12 @@ async def test_abort_if_already_setup(hass):
|
|||||||
with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
|
with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
|
||||||
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"] == "already_configured_account"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
|
with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
|
||||||
result = await flow.async_step_code()
|
result = await flow.async_step_code()
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured_account"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
async def test_full_flow_implementation(hass):
|
async def test_full_flow_implementation(hass):
|
||||||
@ -107,7 +107,7 @@ async def test_already_setup(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"] == "already_configured_account"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
async def test_view(hass):
|
async def test_view(hass):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user