Use reference strings in Vesync (#41341)

* Update strings.json

* Update config_flow.py

* Update test_config_flow.py
This commit is contained in:
SNoof85 2020-10-06 20:00:07 +02:00 committed by GitHub
parent ba81c0c043
commit b8287d6db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View file

@ -51,7 +51,7 @@ class VeSyncFlowHandler(config_entries.ConfigFlow):
async def async_step_user(self, user_input=None):
"""Handle a flow start."""
if configured_instances(self.hass):
return self.async_abort(reason="already_setup")
return self.async_abort(reason="single_instance_allowed")
if not user_input:
return self._show_form()
@ -62,7 +62,7 @@ class VeSyncFlowHandler(config_entries.ConfigFlow):
manager = VeSync(self._username, self._password)
login = await self.hass.async_add_executor_job(manager.login)
if not login:
return self._show_form(errors={"base": "invalid_login"})
return self._show_form(errors={"base": "invalid_auth"})
return self.async_create_entry(
title=self._username,

View file

@ -10,10 +10,10 @@
}
},
"error": {
"invalid_login": "Invalid username or password"
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]"
},
"abort": {
"already_setup": "Only one Vesync instance is allowed"
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
}
}
}
}

View file

@ -17,7 +17,7 @@ async def test_abort_already_setup(hass):
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_setup"
assert result["reason"] == "single_instance_allowed"
async def test_invalid_login_error(hass):
@ -29,7 +29,7 @@ async def test_invalid_login_error(hass):
result = await flow.async_step_user(user_input=test_dict)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["errors"] == {"base": "invalid_login"}
assert result["errors"] == {"base": "invalid_auth"}
async def test_config_flow_configuration_yaml(hass):