Merge UniFi device tracker to config entry (#24367)
* Move device tracker to use config entry * Remove monitored conditions attributes based on ADR0003 * Add support for import of device tracker config to be backwards compatible * Remove unnecessary configuration options from device tracker * Add component configuration support
This commit is contained in:
parent
3480e6229a
commit
01b890f426
11 changed files with 493 additions and 449 deletions
|
@ -1,4 +1,5 @@
|
|||
"""Test UniFi setup process."""
|
||||
from datetime import timedelta
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.components import unifi
|
||||
|
@ -15,6 +16,29 @@ async def test_setup_with_no_config(hass):
|
|||
"""Test that we do not discover anything or try to set up a bridge."""
|
||||
assert await async_setup_component(hass, unifi.DOMAIN, {}) is True
|
||||
assert unifi.DOMAIN not in hass.data
|
||||
assert hass.data[unifi.UNIFI_CONFIG] == []
|
||||
|
||||
|
||||
async def test_setup_with_config(hass):
|
||||
"""Test that we do not discover anything or try to set up a bridge."""
|
||||
config = {
|
||||
unifi.DOMAIN: {
|
||||
unifi.CONF_CONTROLLERS: {
|
||||
unifi.CONF_HOST: '1.2.3.4',
|
||||
unifi.CONF_SITE_ID: 'My site',
|
||||
unifi.CONF_DETECTION_TIME: 3,
|
||||
unifi.CONF_SSID_FILTER: ['ssid']
|
||||
}
|
||||
}
|
||||
}
|
||||
assert await async_setup_component(hass, unifi.DOMAIN, config) is True
|
||||
assert unifi.DOMAIN not in hass.data
|
||||
assert hass.data[unifi.UNIFI_CONFIG] == [{
|
||||
unifi.CONF_HOST: '1.2.3.4',
|
||||
unifi.CONF_SITE_ID: 'My site',
|
||||
unifi.CONF_DETECTION_TIME: timedelta(seconds=3),
|
||||
unifi.CONF_SSID_FILTER: ['ssid']
|
||||
}]
|
||||
|
||||
|
||||
async def test_successful_config_entry(hass):
|
||||
|
@ -247,41 +271,6 @@ async def test_controller_site_already_configured(hass):
|
|||
assert result['type'] == 'abort'
|
||||
|
||||
|
||||
async def test_user_permissions_low(hass, aioclient_mock):
|
||||
"""Test config flow."""
|
||||
flow = config_flow.UnifiFlowHandler()
|
||||
flow.hass = hass
|
||||
|
||||
with patch('aiounifi.Controller') as mock_controller:
|
||||
def mock_constructor(
|
||||
host, username, password, port, site, websession, sslcontext):
|
||||
"""Fake the controller constructor."""
|
||||
mock_controller.host = host
|
||||
mock_controller.username = username
|
||||
mock_controller.password = password
|
||||
mock_controller.port = port
|
||||
mock_controller.site = site
|
||||
return mock_controller
|
||||
|
||||
mock_controller.side_effect = mock_constructor
|
||||
mock_controller.login.return_value = mock_coro()
|
||||
mock_controller.sites.return_value = mock_coro({
|
||||
'site1': {'name': 'default', 'role': 'viewer', 'desc': 'site name'}
|
||||
})
|
||||
|
||||
await flow.async_step_user(user_input={
|
||||
CONF_HOST: '1.2.3.4',
|
||||
CONF_USERNAME: 'username',
|
||||
CONF_PASSWORD: 'password',
|
||||
CONF_PORT: 1234,
|
||||
CONF_VERIFY_SSL: True
|
||||
})
|
||||
|
||||
result = await flow.async_step_site(user_input={})
|
||||
|
||||
assert result['type'] == 'abort'
|
||||
|
||||
|
||||
async def test_user_credentials_faulty(hass, aioclient_mock):
|
||||
"""Test config flow."""
|
||||
flow = config_flow.UnifiFlowHandler()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue