mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
UniFi config entry options (#26113)
Introduce config entry options for Unifi integration Allow configuration.yaml options to be imported to new options
This commit is contained in:
@@ -250,7 +250,7 @@ def mock_controller(hass):
|
||||
return controller
|
||||
|
||||
|
||||
async def setup_controller(hass, mock_controller):
|
||||
async def setup_controller(hass, mock_controller, options={}):
|
||||
"""Load the UniFi switch platform with the provided controller."""
|
||||
hass.config.components.add(unifi.DOMAIN)
|
||||
hass.data[unifi.DOMAIN] = {CONTROLLER_ID: mock_controller}
|
||||
@@ -263,6 +263,7 @@ async def setup_controller(hass, mock_controller):
|
||||
config_entries.CONN_CLASS_LOCAL_POLL,
|
||||
entry_id=1,
|
||||
system_options={},
|
||||
options=options,
|
||||
)
|
||||
mock_controller.config_entry = config_entry
|
||||
|
||||
@@ -320,11 +321,9 @@ async def test_switches(hass, mock_controller):
|
||||
mock_controller.mock_client_responses.append([CLIENT_1, CLIENT_4])
|
||||
mock_controller.mock_device_responses.append([DEVICE_1])
|
||||
mock_controller.mock_client_all_responses.append([BLOCKED, UNBLOCKED, CLIENT_1])
|
||||
mock_controller.unifi_config = {
|
||||
unifi.CONF_BLOCK_CLIENT: [BLOCKED["mac"], UNBLOCKED["mac"]]
|
||||
}
|
||||
options = {unifi.CONF_BLOCK_CLIENT: [BLOCKED["mac"], UNBLOCKED["mac"]]}
|
||||
|
||||
await setup_controller(hass, mock_controller)
|
||||
await setup_controller(hass, mock_controller, options)
|
||||
assert len(mock_controller.mock_requests) == 3
|
||||
assert len(hass.states.async_all()) == 5
|
||||
|
||||
@@ -467,7 +466,7 @@ async def test_restoring_client(hass, mock_controller):
|
||||
mock_controller.mock_client_responses.append([CLIENT_2])
|
||||
mock_controller.mock_device_responses.append([DEVICE_1])
|
||||
mock_controller.mock_client_all_responses.append([CLIENT_1])
|
||||
mock_controller.unifi_config = {unifi.CONF_BLOCK_CLIENT: ["random mac"]}
|
||||
options = {unifi.CONF_BLOCK_CLIENT: ["random mac"]}
|
||||
|
||||
config_entry = config_entries.ConfigEntry(
|
||||
1,
|
||||
@@ -496,7 +495,7 @@ async def test_restoring_client(hass, mock_controller):
|
||||
config_entry=config_entry,
|
||||
)
|
||||
|
||||
await setup_controller(hass, mock_controller)
|
||||
await setup_controller(hass, mock_controller, options)
|
||||
assert len(mock_controller.mock_requests) == 3
|
||||
assert len(hass.states.async_all()) == 3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user