Use common strings for somfy config flow (#40594)

This commit is contained in:
Rob Bierbooms 2020-09-26 13:30:49 +02:00 committed by GitHub
parent c011f3fa95
commit f6435affe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -24,6 +24,6 @@ class SomfyFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
async def async_step_user(self, user_input=None): async def async_step_user(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_setup") return self.async_abort(reason="single_instance_allowed")
return await super().async_step_user(user_input) return await super().async_step_user(user_input)

View file

@ -4,11 +4,13 @@
"pick_implementation": { "title": "Pick Authentication Method" } "pick_implementation": { "title": "Pick Authentication Method" }
}, },
"abort": { "abort": {
"already_setup": "You can only configure one Somfy account.", "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]",
"authorize_url_timeout": "Timeout generating authorize url.", "authorize_url_timeout": "Timeout generating authorize url.",
"missing_configuration": "The Somfy component is not configured. Please follow the documentation.", "missing_configuration": "The Somfy component is not configured. Please follow the documentation.",
"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": { "default": "Successfully authenticated with Somfy." } "create_entry": {
"default": "[%key:common::config_flow::create_entry::authenticated%]"
}
} }
} }

View file

@ -49,7 +49,7 @@ async def test_abort_if_existing_entry(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_setup" assert result["reason"] == "single_instance_allowed"
async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request): async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request):