UniFi - Store controller in config_entry.entry_id (#34553)
* Store controller in config_entry.entry_id * Clean up imports
This commit is contained in:
1 parent
a0fbf9ba47
commit
c3689d7416
13 files changed
+190
-182
No files matched your search
@@ -3,8 +3,6 @@ import aiounifi
|
||||
from asynctest import patch
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import unifi
|
||||
from homeassistant.components.unifi import config_flow
|
||||
from homeassistant.components.unifi.const import (
|
||||
CONF_ALLOW_BANDWIDTH_SENSORS,
|
||||
CONF_BLOCK_CLIENT,
|
||||
@@ -17,6 +15,7 @@ from homeassistant.components.unifi.const import (
|
||||
CONF_TRACK_CLIENTS,
|
||||
CONF_TRACK_DEVICES,
|
||||
CONF_TRACK_WIRED_CLIENTS,
|
||||
DOMAIN as UNIFI_DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
@@ -39,7 +38,7 @@ async def test_flow_works(hass, aioclient_mock, mock_discovery):
|
||||
"""Test config flow."""
|
||||
mock_discovery.return_value = "1"
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": "user"}
|
||||
UNIFI_DOMAIN, context={"source": "user"}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -97,7 +96,7 @@ async def test_flow_works(hass, aioclient_mock, mock_discovery):
|
||||
async def test_flow_works_multiple_sites(hass, aioclient_mock):
|
||||
"""Test config flow works when finding multiple sites."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": "user"}
|
||||
UNIFI_DOMAIN, context={"source": "user"}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -143,12 +142,12 @@ async def test_flow_works_multiple_sites(hass, aioclient_mock):
|
||||
async def test_flow_fails_site_already_configured(hass, aioclient_mock):
|
||||
"""Test config flow."""
|
||||
entry = MockConfigEntry(
|
||||
domain=unifi.DOMAIN, data={"controller": {"host": "1.2.3.4", "site": "site_id"}}
|
||||
domain=UNIFI_DOMAIN, data={"controller": {"host": "1.2.3.4", "site": "site_id"}}
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": "user"}
|
||||
UNIFI_DOMAIN, context={"source": "user"}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -188,7 +187,7 @@ async def test_flow_fails_site_already_configured(hass, aioclient_mock):
|
||||
async def test_flow_fails_user_credentials_faulty(hass, aioclient_mock):
|
||||
"""Test config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": "user"}
|
||||
UNIFI_DOMAIN, context={"source": "user"}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -215,7 +214,7 @@ async def test_flow_fails_user_credentials_faulty(hass, aioclient_mock):
|
||||
async def test_flow_fails_controller_unavailable(hass, aioclient_mock):
|
||||
"""Test config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": "user"}
|
||||
UNIFI_DOMAIN, context={"source": "user"}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -242,7 +241,7 @@ async def test_flow_fails_controller_unavailable(hass, aioclient_mock):
|
||||
async def test_flow_fails_unknown_problem(hass, aioclient_mock):
|
||||
"""Test config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": "user"}
|
||||
UNIFI_DOMAIN, context={"source": "user"}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
||||
Reference in new issue
Block a user