Address late IntelliFire review (#70461)

* Addressing MartinHjelmare comments in closed PR

* updated tests accordingly

* Update tests/components/intellifire/test_config_flow.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/components/intellifire/test_config_flow.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* updated error message

* addressing late review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
pull/70841/head
Jeef 2022-04-26 23:07:30 -06:00 committed by GitHub
parent 56000c0378
commit 4a6ea5afd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 24 deletions

View File

@ -128,21 +128,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
}
)
if user_input[CONF_USERNAME] != "":
try:
return await self.validate_api_access_and_create_or_update(
host=self._host,
username=user_input[CONF_USERNAME],
password=user_input[CONF_PASSWORD],
serial=self._serial,
)
try:
return await self.validate_api_access_and_create_or_update(
host=self._host,
username=user_input[CONF_USERNAME],
password=user_input[CONF_PASSWORD],
serial=self._serial,
)
except (ConnectionError, ClientConnectionError):
errors["base"] = "iftapi_connect"
LOGGER.info("ERROR: iftapi_connect")
except LoginException:
errors["base"] = "api_error"
LOGGER.info("ERROR: api_error")
except (ConnectionError, ClientConnectionError):
errors["base"] = "iftapi_connect"
LOGGER.error(
"Could not connect to iftapi.net over https - verify connectivity"
)
except LoginException:
errors["base"] = "api_error"
LOGGER.error("Invalid credentials for iftapi.net")
return self.async_show_form(
step_id="api_config", errors=errors, data_schema=control_schema

View File

@ -5,7 +5,7 @@
"manual_device_entry": {
"description": "Local Configuration",
"data": {
"host": "[%key:common::config_flow::data::host%] (IP Address)"
"host": "Host (IP Address)"
}
},
"api_config": {

View File

@ -299,17 +299,14 @@ async def test_reauth_flow(
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "api_config"
with patch(
"homeassistant.config_entries.ConfigFlow.async_set_unique_id",
return_value=entry,
):
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_USERNAME: "test", CONF_PASSWORD: "AROONIE"},
)
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_USERNAME: "test", CONF_PASSWORD: "AROONIE"},
)
await hass.async_block_till_done()
assert result3["type"] == RESULT_TYPE_ABORT
assert entry.data[CONF_PASSWORD] == "AROONIE"
assert entry.data[CONF_USERNAME] == "test"
async def test_dhcp_discovery_intellifire_device(