Bump total_connect_client to 2021.11.2 (#58818)

* update total_connect_client to 2021.10

* update for total_connect_client changes

* remove unused return value

* bump total_connect_client to 2021.11.1

* bump total_connect_client to 2021.11.2

* Move to public ResultCode

* load locations to prevent 'unknown error occurred'

* add test for zero locations

* Revert "load locations to prevent 'unknown error occurred'"

This reverts commit 28b8984be5.

* Revert "add test for zero locations"

This reverts commit 77bf7908d5.
This commit is contained in:
Austin Mroczek 2021-11-07 15:30:34 -08:00 committed by GitHub
parent 55cd1ffb7c
commit 72aaeda8a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 25 deletions

View file

@ -38,7 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
TotalConnectClient, username, password, usercodes TotalConnectClient, username, password, usercodes
) )
if not client.is_valid_credentials(): if not client.is_logged_in():
raise ConfigEntryAuthFailed("TotalConnect authentication failed") raise ConfigEntryAuthFailed("TotalConnect authentication failed")
coordinator = TotalConnectDataUpdateCoordinator(hass, client) coordinator = TotalConnectDataUpdateCoordinator(hass, client)
@ -88,5 +88,3 @@ class TotalConnectDataUpdateCoordinator(DataUpdateCoordinator):
raise UpdateFailed(exception) from exception raise UpdateFailed(exception) from exception
except ValueError as exception: except ValueError as exception:
raise UpdateFailed("Unknown state from TotalConnect") from exception raise UpdateFailed("Unknown state from TotalConnect") from exception
return True

View file

@ -40,7 +40,7 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
TotalConnectClient, username, password, None TotalConnectClient, username, password, None
) )
if client.is_valid_credentials(): if client.is_logged_in():
# username/password valid so show user locations # username/password valid so show user locations
self.username = username self.username = username
self.password = password self.password = password
@ -136,7 +136,7 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self.usercodes, self.usercodes,
) )
if not client.is_valid_credentials(): if not client.is_logged_in():
errors["base"] = "invalid_auth" errors["base"] = "invalid_auth"
return self.async_show_form( return self.async_show_form(
step_id="reauth_confirm", step_id="reauth_confirm",

View file

@ -2,7 +2,7 @@
"domain": "totalconnect", "domain": "totalconnect",
"name": "Total Connect", "name": "Total Connect",
"documentation": "https://www.home-assistant.io/integrations/totalconnect", "documentation": "https://www.home-assistant.io/integrations/totalconnect",
"requirements": ["total_connect_client==2021.8.3"], "requirements": ["total_connect_client==2021.11.2"],
"dependencies": [], "dependencies": [],
"codeowners": ["@austinmroczek"], "codeowners": ["@austinmroczek"],
"config_flow": true, "config_flow": true,

View file

@ -2320,7 +2320,7 @@ todoist-python==8.0.0
toonapi==0.2.1 toonapi==0.2.1
# homeassistant.components.totalconnect # homeassistant.components.totalconnect
total_connect_client==2021.8.3 total_connect_client==2021.11.2
# homeassistant.components.tplink_lte # homeassistant.components.tplink_lte
tp-connected==0.0.4 tp-connected==0.0.4

View file

@ -1339,7 +1339,7 @@ tesla-powerwall==0.3.12
toonapi==0.2.1 toonapi==0.2.1
# homeassistant.components.totalconnect # homeassistant.components.totalconnect
total_connect_client==2021.8.3 total_connect_client==2021.11.2
# homeassistant.components.transmission # homeassistant.components.transmission
transmissionrpc==0.11 transmissionrpc==0.11

View file

@ -1,9 +1,7 @@
"""Common methods used across tests for TotalConnect.""" """Common methods used across tests for TotalConnect."""
from unittest.mock import patch from unittest.mock import patch
from total_connect_client.client import TotalConnectClient from total_connect_client import ArmingState, ResultCode, ZoneStatus, ZoneType
from total_connect_client.const import ArmingState
from total_connect_client.zone import ZoneStatus, ZoneType
from homeassistant.components.totalconnect.const import CONF_USERCODES, DOMAIN from homeassistant.components.totalconnect.const import CONF_USERCODES, DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
@ -44,7 +42,7 @@ USER = {
} }
RESPONSE_AUTHENTICATE = { RESPONSE_AUTHENTICATE = {
"ResultCode": TotalConnectClient.SUCCESS, "ResultCode": ResultCode.SUCCESS.value,
"SessionID": 1, "SessionID": 1,
"Locations": LOCATIONS, "Locations": LOCATIONS,
"ModuleFlags": MODULE_FLAGS, "ModuleFlags": MODULE_FLAGS,
@ -52,7 +50,7 @@ RESPONSE_AUTHENTICATE = {
} }
RESPONSE_AUTHENTICATE_FAILED = { RESPONSE_AUTHENTICATE_FAILED = {
"ResultCode": TotalConnectClient.BAD_USER_OR_PASSWORD, "ResultCode": ResultCode.BAD_USER_OR_PASSWORD.value,
"ResultData": "test bad authentication", "ResultData": "test bad authentication",
} }
@ -255,18 +253,18 @@ RESPONSE_UNKNOWN = {
"ArmingState": ArmingState.DISARMED, "ArmingState": ArmingState.DISARMED,
} }
RESPONSE_ARM_SUCCESS = {"ResultCode": TotalConnectClient.ARM_SUCCESS} RESPONSE_ARM_SUCCESS = {"ResultCode": ResultCode.ARM_SUCCESS.value}
RESPONSE_ARM_FAILURE = {"ResultCode": TotalConnectClient.COMMAND_FAILED} RESPONSE_ARM_FAILURE = {"ResultCode": ResultCode.COMMAND_FAILED.value}
RESPONSE_DISARM_SUCCESS = {"ResultCode": TotalConnectClient.DISARM_SUCCESS} RESPONSE_DISARM_SUCCESS = {"ResultCode": ResultCode.DISARM_SUCCESS.value}
RESPONSE_DISARM_FAILURE = { RESPONSE_DISARM_FAILURE = {
"ResultCode": TotalConnectClient.COMMAND_FAILED, "ResultCode": ResultCode.COMMAND_FAILED.value,
"ResultData": "Command Failed", "ResultData": "Command Failed",
} }
RESPONSE_USER_CODE_INVALID = { RESPONSE_USER_CODE_INVALID = {
"ResultCode": TotalConnectClient.USER_CODE_INVALID, "ResultCode": ResultCode.USER_CODE_INVALID.value,
"ResultData": "testing user code invalid", "ResultData": "testing user code invalid",
} }
RESPONSE_SUCCESS = {"ResultCode": TotalConnectClient.SUCCESS} RESPONSE_SUCCESS = {"ResultCode": ResultCode.SUCCESS.value}
USERNAME = "username@me.com" USERNAME = "username@me.com"
PASSWORD = "password" PASSWORD = "password"
@ -292,7 +290,7 @@ PARTITION_DETAILS_2 = {
PARTITION_DETAILS = {"PartitionDetails": [PARTITION_DETAILS_1, PARTITION_DETAILS_2]} PARTITION_DETAILS = {"PartitionDetails": [PARTITION_DETAILS_1, PARTITION_DETAILS_2]}
RESPONSE_PARTITION_DETAILS = { RESPONSE_PARTITION_DETAILS = {
"ResultCode": TotalConnectClient.SUCCESS, "ResultCode": ResultCode.SUCCESS.value,
"ResultData": "testing partition details", "ResultData": "testing partition details",
"PartitionsInfoList": PARTITION_DETAILS, "PartitionsInfoList": PARTITION_DETAILS,
} }

View file

@ -95,7 +95,7 @@ async def test_abort_if_already_setup(hass):
with patch( with patch(
"homeassistant.components.totalconnect.config_flow.TotalConnectClient" "homeassistant.components.totalconnect.config_flow.TotalConnectClient"
) as client_mock: ) as client_mock:
client_mock.return_value.is_valid_credentials.return_value = True client_mock.return_value.is_logged_in.return_value = True
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
@ -111,7 +111,7 @@ async def test_login_failed(hass):
with patch( with patch(
"homeassistant.components.totalconnect.config_flow.TotalConnectClient" "homeassistant.components.totalconnect.config_flow.TotalConnectClient"
) as client_mock: ) as client_mock:
client_mock.return_value.is_valid_credentials.return_value = False client_mock.return_value.is_logged_in.return_value = False
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
@ -143,7 +143,7 @@ async def test_reauth(hass):
"homeassistant.components.totalconnect.async_setup_entry", return_value=True "homeassistant.components.totalconnect.async_setup_entry", return_value=True
): ):
# first test with an invalid password # first test with an invalid password
client_mock.return_value.is_valid_credentials.return_value = False client_mock.return_value.is_logged_in.return_value = False
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_PASSWORD: "password"} result["flow_id"], user_input={CONF_PASSWORD: "password"}
@ -153,7 +153,7 @@ async def test_reauth(hass):
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
# now test with the password valid # now test with the password valid
client_mock.return_value.is_valid_credentials.return_value = True client_mock.return_value.is_logged_in.return_value = True
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_PASSWORD: "password"} result["flow_id"], user_input={CONF_PASSWORD: "password"}

View file

@ -22,7 +22,7 @@ async def test_reauth_started(hass):
"homeassistant.components.totalconnect.TotalConnectClient", "homeassistant.components.totalconnect.TotalConnectClient",
autospec=True, autospec=True,
) as mock_client: ) as mock_client:
mock_client.return_value.is_valid_credentials.return_value = False mock_client.return_value.is_logged_in.return_value = False
assert await async_setup_component(hass, DOMAIN, {}) assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done() await hass.async_block_till_done()