Skip to content

Commit

Permalink
Address late IntelliFire review (home-assistant#70461)
Browse files Browse the repository at this point in the history
* Addressing MartinHjelmare comments in closed PR

* updated tests accordingly

* Update tests/components/intellifire/test_config_flow.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update tests/components/intellifire/test_config_flow.py

Co-authored-by: Martin Hjelmare <[email protected]>

* updated error message

* addressing late review

Co-authored-by: Martin Hjelmare <[email protected]>
  • Loading branch information
jeeftor and MartinHjelmare authored Apr 27, 2022
1 parent 56000c0 commit 4a6ea5a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
29 changes: 15 additions & 14 deletions homeassistant/components/intellifire/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,22 @@ async def async_step_api_config(
}
)

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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/intellifire/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
15 changes: 6 additions & 9 deletions tests/components/intellifire/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4a6ea5a

Please sign in to comment.