core/tests/components/aladdin_connect/test_init.py

260 lines
8.6 KiB
Python
Raw Normal View History

Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
"""Test for Aladdin Connect init logic."""
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
from unittest.mock import MagicMock, patch
from AIOAladdinConnect.session_manager import InvalidPasswordError
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
from aiohttp import ClientConnectionError
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
from homeassistant.components.aladdin_connect.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from .conftest import DEVICE_CONFIG_OPEN
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
from tests.common import AsyncMock, MockConfigEntry
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
CONFIG = {"username": "test-user", "password": "test-password"}
ID = "533255-1"
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
async def test_setup_get_doors_errors(hass: HomeAssistant) -> None:
"""Test component setup Get Doors Errors."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data=CONFIG,
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
unique_id="test-id",
)
config_entry.add_to_hass(hass)
with (
patch(
"homeassistant.components.aladdin_connect.cover.AladdinConnectClient.login",
return_value=True,
),
patch(
"homeassistant.components.aladdin_connect.cover.AladdinConnectClient.get_doors",
return_value=None,
),
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
):
assert await hass.config_entries.async_setup(config_entry.entry_id) is True
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 0
async def test_setup_login_error(
hass: HomeAssistant, mock_aladdinconnect_api: MagicMock
) -> None:
"""Test component setup Login Errors."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data=CONFIG,
unique_id=ID,
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
)
config_entry.add_to_hass(hass)
mock_aladdinconnect_api.login.return_value = False
mock_aladdinconnect_api.login.side_effect = InvalidPasswordError
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
with patch(
"homeassistant.components.aladdin_connect.cover.AladdinConnectClient",
return_value=mock_aladdinconnect_api,
):
assert await hass.config_entries.async_setup(config_entry.entry_id) is False
async def test_setup_connection_error(
hass: HomeAssistant, mock_aladdinconnect_api: MagicMock
) -> None:
"""Test component setup Login Errors."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data=CONFIG,
unique_id=ID,
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
)
config_entry.add_to_hass(hass)
mock_aladdinconnect_api.login.side_effect = ClientConnectionError
with patch(
"homeassistant.components.aladdin_connect.AladdinConnectClient",
return_value=mock_aladdinconnect_api,
):
assert await hass.config_entries.async_setup(config_entry.entry_id) is False
async def test_setup_component_no_error(hass: HomeAssistant) -> None:
"""Test component setup No Error."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data=CONFIG,
unique_id=ID,
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
)
config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.aladdin_connect.cover.AladdinConnectClient.login",
return_value=True,
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
async def test_entry_password_fail(
hass: HomeAssistant, mock_aladdinconnect_api: MagicMock
) -> None:
"""Test password fail during entry."""
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
entry = MockConfigEntry(
domain=DOMAIN,
data={"username": "test-user", "password": "test-password"},
)
entry.add_to_hass(hass)
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
mock_aladdinconnect_api.login = AsyncMock(return_value=False)
mock_aladdinconnect_api.login.side_effect = InvalidPasswordError
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
with patch(
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
"homeassistant.components.aladdin_connect.AladdinConnectClient",
return_value=mock_aladdinconnect_api,
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
assert entry.state is ConfigEntryState.SETUP_ERROR
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
async def test_load_and_unload(
hass: HomeAssistant, mock_aladdinconnect_api: MagicMock
) -> None:
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
"""Test loading and unloading Aladdin Connect entry."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data=CONFIG,
unique_id=ID,
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
)
config_entry.add_to_hass(hass)
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
with patch(
Move to async for aladdin connect integration (#73954) * Moved to AIOAladdinConnect API * Added callback logic for door status * close unused connections * Close connection after verification * Matched to current version * Matched __init__.py to current release * Matched cover.py to existing version * added missing awaits * Moved callback * Bumped AIOAladdinConnect to 0.1.3 * Removed await from callback config * Finished tests * Added callback test * Bumped AIOAladdinConnect to 0.1.4 * Finished tests * Callback correct call to update HA * Modified calls to state machine * Modified update path * Removed unused status * Bumped AIOAladdinConnect to 0.1.7 * Revised test_cover cover tests and bumped AIOAladdinConnect to 0.1.10 * Bumped AIOAladdinConnect to 0.1.11 * Bumped AIOAladdinConenct to 0.1.12 * Bumped AIOAladdinConnect to 0.1.13 * Bumped AIOAladdinConnect to 0.1.14 * Added ability to handle multiple doors * Added timout errors to config flow * asyncio timout error added to setup retry * Cleanup added to hass proceedure * Bumped AIOAladdinConnect to 0.1.16 * Bumped AIOAladdinConnect to 0.1.18 * Bumped AIOAladdinConnect to 0.1.19 * Bumped AIOAladdinConnect to 0.1.20 * Addressed recommended changes: SCAN_INTERVAL and spelling * Moved to async_get_clientsession and bumped AIOAladdinConnect to 0.1.21 * Missing test for new code structure * removed extra call to write_ha_state, callback decorator, cleaned up tests * Update tests/components/aladdin_connect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Removed extra_attributes. * Added typing to variable acc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-28 21:22:18 +00:00
"homeassistant.components.aladdin_connect.AladdinConnectClient",
return_value=mock_aladdinconnect_api,
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert await hass.config_entries.async_unload(config_entry.entry_id)
Add Aladdin connect config flow (#68304) * Adding flow and async * Fixes to init * Lint and type * Fixed coveragerc file * Added Test Coverage * Added Update Listener and removed unused code * Wrong integration name in init. * Nothing * Added yaml import flow * Added YAML import functionality * Added back aladdin_connect files to coverage rc * Removed commented code * Clean up error message * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/__init__.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: G Johansson <goran.johansson@shiftit.se> * Updated Documentation errors * recommended change broke cover.py - backed out * Cleaned up unused defenitions * implimented recommended changes from gjohansson * Dev environment cleanup * Raised errors for better recovery, replaced removed update files, utilized PLATFORM vars to init platform * Added back removal * Added Code Owner * Fixed more comment errors and import duplicates * Added test coverage and formated code * Added test coverage for model and init * Added test_cover for full testing coverage * Added await to async call * Added missing asserts to failure tests * Updated tranlsation * Fixed wording in yaml import function, white space in const.py, return from validate_input. * Update homeassistant/components/aladdin_connect/config_flow.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> * "too much" whitespace * Added back mising strings.json errors * Added ConfigFlowReconfig and tests * Finished up reauth config flow and associated tests * Added reauth to strings, removed username from reauth * recommended changes, ran script.translations, added auth test to reauth * put back self.entry.data unpack. * Cleanup for error message, fixed missing "asserts" in tests * Added yaml import assertions * Fixed documentation errors in test_cover. * remove unused string. * revised tests and wording for yaml import * Documentation cleanup. * Changed sideeffect names Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2022-05-13 22:41:01 +00:00
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.NOT_LOADED
async def test_stale_device_removal(
hass: HomeAssistant, mock_aladdinconnect_api: MagicMock
) -> None:
"""Test component setup missing door device is removed."""
DEVICE_CONFIG_DOOR_2 = {
"device_id": 533255,
"door_number": 2,
"name": "home 2",
"status": "open",
"link_status": "Connected",
"serial": "12346",
"model": "02",
}
config_entry = MockConfigEntry(
domain=DOMAIN,
data=CONFIG,
unique_id=ID,
)
config_entry.add_to_hass(hass)
mock_aladdinconnect_api.get_doors = AsyncMock(
return_value=[DEVICE_CONFIG_OPEN, DEVICE_CONFIG_DOOR_2]
)
config_entry_other = MockConfigEntry(
domain="OtherDomain",
data=CONFIG,
unique_id="unique_id",
)
config_entry_other.add_to_hass(hass)
device_registry = dr.async_get(hass)
device_entry_other = device_registry.async_get_or_create(
config_entry_id=config_entry_other.entry_id,
identifiers={("OtherDomain", "533255-2")},
)
device_registry.async_update_device(
device_entry_other.id,
add_config_entry_id=config_entry.entry_id,
merge_identifiers={(DOMAIN, "533255-2")},
)
with patch(
"homeassistant.components.aladdin_connect.AladdinConnectClient",
return_value=mock_aladdinconnect_api,
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
device_registry = dr.async_get(hass)
device_entries = dr.async_entries_for_config_entry(
device_registry, config_entry.entry_id
)
assert len(device_entries) == 2
assert any((DOMAIN, "533255-1") in device.identifiers for device in device_entries)
assert any((DOMAIN, "533255-2") in device.identifiers for device in device_entries)
assert any(
("OtherDomain", "533255-2") in device.identifiers for device in device_entries
)
device_entries_other = dr.async_entries_for_config_entry(
device_registry, config_entry_other.entry_id
)
assert len(device_entries_other) == 1
assert any(
(DOMAIN, "533255-2") in device.identifiers for device in device_entries_other
)
assert any(
("OtherDomain", "533255-2") in device.identifiers
for device in device_entries_other
)
assert await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.NOT_LOADED
mock_aladdinconnect_api.get_doors = AsyncMock(return_value=[DEVICE_CONFIG_OPEN])
with patch(
"homeassistant.components.aladdin_connect.AladdinConnectClient",
return_value=mock_aladdinconnect_api,
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
device_entries = dr.async_entries_for_config_entry(
device_registry, config_entry.entry_id
)
assert len(device_entries) == 1
assert any((DOMAIN, "533255-1") in device.identifiers for device in device_entries)
assert not any(
(DOMAIN, "533255-2") in device.identifiers for device in device_entries
)
assert not any(
("OtherDomain", "533255-2") in device.identifiers for device in device_entries
)
device_entries_other = dr.async_entries_for_config_entry(
device_registry, config_entry_other.entry_id
)
assert len(device_entries_other) == 1
assert any(
("OtherDomain", "533255-2") in device.identifiers
for device in device_entries_other
)
assert any(
(DOMAIN, "533255-2") in device.identifiers for device in device_entries_other
)