mirror of
https://github.com/home-assistant/core.git
synced 2026-11-27 16:17:33 -04:00
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 commit28b8984be5. * Revert "add test for zero locations" This reverts commit77bf7908d5.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
"""Common methods used across tests for TotalConnect."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from total_connect_client.client import TotalConnectClient
|
||||
from total_connect_client.const import ArmingState
|
||||
from total_connect_client.zone import ZoneStatus, ZoneType
|
||||
from total_connect_client import ArmingState, ResultCode, ZoneStatus, ZoneType
|
||||
|
||||
from homeassistant.components.totalconnect.const import CONF_USERCODES, DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
@@ -44,7 +42,7 @@ USER = {
|
||||
}
|
||||
|
||||
RESPONSE_AUTHENTICATE = {
|
||||
"ResultCode": TotalConnectClient.SUCCESS,
|
||||
"ResultCode": ResultCode.SUCCESS.value,
|
||||
"SessionID": 1,
|
||||
"Locations": LOCATIONS,
|
||||
"ModuleFlags": MODULE_FLAGS,
|
||||
@@ -52,7 +50,7 @@ RESPONSE_AUTHENTICATE = {
|
||||
}
|
||||
|
||||
RESPONSE_AUTHENTICATE_FAILED = {
|
||||
"ResultCode": TotalConnectClient.BAD_USER_OR_PASSWORD,
|
||||
"ResultCode": ResultCode.BAD_USER_OR_PASSWORD.value,
|
||||
"ResultData": "test bad authentication",
|
||||
}
|
||||
|
||||
@@ -255,18 +253,18 @@ RESPONSE_UNKNOWN = {
|
||||
"ArmingState": ArmingState.DISARMED,
|
||||
}
|
||||
|
||||
RESPONSE_ARM_SUCCESS = {"ResultCode": TotalConnectClient.ARM_SUCCESS}
|
||||
RESPONSE_ARM_FAILURE = {"ResultCode": TotalConnectClient.COMMAND_FAILED}
|
||||
RESPONSE_DISARM_SUCCESS = {"ResultCode": TotalConnectClient.DISARM_SUCCESS}
|
||||
RESPONSE_ARM_SUCCESS = {"ResultCode": ResultCode.ARM_SUCCESS.value}
|
||||
RESPONSE_ARM_FAILURE = {"ResultCode": ResultCode.COMMAND_FAILED.value}
|
||||
RESPONSE_DISARM_SUCCESS = {"ResultCode": ResultCode.DISARM_SUCCESS.value}
|
||||
RESPONSE_DISARM_FAILURE = {
|
||||
"ResultCode": TotalConnectClient.COMMAND_FAILED,
|
||||
"ResultCode": ResultCode.COMMAND_FAILED.value,
|
||||
"ResultData": "Command Failed",
|
||||
}
|
||||
RESPONSE_USER_CODE_INVALID = {
|
||||
"ResultCode": TotalConnectClient.USER_CODE_INVALID,
|
||||
"ResultCode": ResultCode.USER_CODE_INVALID.value,
|
||||
"ResultData": "testing user code invalid",
|
||||
}
|
||||
RESPONSE_SUCCESS = {"ResultCode": TotalConnectClient.SUCCESS}
|
||||
RESPONSE_SUCCESS = {"ResultCode": ResultCode.SUCCESS.value}
|
||||
|
||||
USERNAME = "username@me.com"
|
||||
PASSWORD = "password"
|
||||
@@ -292,7 +290,7 @@ PARTITION_DETAILS_2 = {
|
||||
|
||||
PARTITION_DETAILS = {"PartitionDetails": [PARTITION_DETAILS_1, PARTITION_DETAILS_2]}
|
||||
RESPONSE_PARTITION_DETAILS = {
|
||||
"ResultCode": TotalConnectClient.SUCCESS,
|
||||
"ResultCode": ResultCode.SUCCESS.value,
|
||||
"ResultData": "testing partition details",
|
||||
"PartitionsInfoList": PARTITION_DETAILS,
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ async def test_abort_if_already_setup(hass):
|
||||
with patch(
|
||||
"homeassistant.components.totalconnect.config_flow.TotalConnectClient"
|
||||
) 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(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
@@ -111,7 +111,7 @@ async def test_login_failed(hass):
|
||||
with patch(
|
||||
"homeassistant.components.totalconnect.config_flow.TotalConnectClient"
|
||||
) 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(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
@@ -143,7 +143,7 @@ async def test_reauth(hass):
|
||||
"homeassistant.components.totalconnect.async_setup_entry", return_value=True
|
||||
):
|
||||
# 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["flow_id"], user_input={CONF_PASSWORD: "password"}
|
||||
@@ -153,7 +153,7 @@ async def test_reauth(hass):
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
# 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["flow_id"], user_input={CONF_PASSWORD: "password"}
|
||||
|
||||
@@ -22,7 +22,7 @@ async def test_reauth_started(hass):
|
||||
"homeassistant.components.totalconnect.TotalConnectClient",
|
||||
autospec=True,
|
||||
) 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, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user