1
mirror of https://github.com/home-assistant/core synced 2024-07-27 18:58:57 +02:00

Use common strings in fritzbox config flow (#41407)

Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
This commit is contained in:
scheric 2020-10-08 18:12:04 +02:00 committed by GitHub
parent d8aebe145b
commit 5345e9fb5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -31,8 +31,8 @@ DATA_SCHEMA_CONFIRM = vol.Schema(
}
)
RESULT_AUTH_FAILED = "auth_failed"
RESULT_NOT_FOUND = "not_found"
RESULT_INVALID_AUTH = "invalid_auth"
RESULT_NO_DEVICES_FOUND = "no_devices_found"
RESULT_NOT_SUPPORTED = "not_supported"
RESULT_SUCCESS = "success"
@ -73,11 +73,11 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
fritzbox.logout()
return RESULT_SUCCESS
except LoginError:
return RESULT_AUTH_FAILED
return RESULT_INVALID_AUTH
except HTTPError:
return RESULT_NOT_SUPPORTED
except OSError:
return RESULT_NOT_FOUND
return RESULT_NO_DEVICES_FOUND
async def async_step_import(self, user_input=None):
"""Handle configuration by yaml file."""
@ -102,7 +102,7 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
if result == RESULT_SUCCESS:
return self._get_entry()
if result != RESULT_AUTH_FAILED:
if result != RESULT_INVALID_AUTH:
return self.async_abort(reason=result)
errors["base"] = result
@ -150,7 +150,7 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
if result == RESULT_SUCCESS:
return self._get_entry()
if result != RESULT_AUTH_FAILED:
if result != RESULT_INVALID_AUTH:
return self.async_abort(reason=result)
errors["base"] = result

View File

@ -20,12 +20,12 @@
},
"abort": {
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
"already_configured": "This AVM FRITZ!Box is already configured.",
"not_found": "No supported AVM FRITZ!Box found on the network.",
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]",
"not_supported": "Connected to AVM FRITZ!Box but it's unable to control Smart Home devices."
},
"error": {
"auth_failed": "Username and/or password are incorrect."
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]"
}
}
}

View File

@ -61,7 +61,7 @@ async def test_user_auth_failed(hass: HomeAssistantType, fritz: Mock):
)
assert result["type"] == "form"
assert result["step_id"] == "user"
assert result["errors"]["base"] == "auth_failed"
assert result["errors"]["base"] == "invalid_auth"
async def test_user_not_successful(hass: HomeAssistantType, fritz: Mock):
@ -72,7 +72,7 @@ async def test_user_not_successful(hass: HomeAssistantType, fritz: Mock):
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
)
assert result["type"] == "abort"
assert result["reason"] == "not_found"
assert result["reason"] == "no_devices_found"
async def test_user_already_configured(hass: HomeAssistantType, fritz: Mock):
@ -162,7 +162,7 @@ async def test_ssdp_auth_failed(hass: HomeAssistantType, fritz: Mock):
)
assert result["type"] == "form"
assert result["step_id"] == "confirm"
assert result["errors"]["base"] == "auth_failed"
assert result["errors"]["base"] == "invalid_auth"
async def test_ssdp_not_successful(hass: HomeAssistantType, fritz: Mock):
@ -180,7 +180,7 @@ async def test_ssdp_not_successful(hass: HomeAssistantType, fritz: Mock):
user_input={CONF_PASSWORD: "whatever", CONF_USERNAME: "whatever"},
)
assert result["type"] == "abort"
assert result["reason"] == "not_found"
assert result["reason"] == "no_devices_found"
async def test_ssdp_not_supported(hass: HomeAssistantType, fritz: Mock):