Remove legacy constant from UniFi (#84947)

pull/84955/head
Robert Svensson 2023-01-01 20:03:14 +01:00 committed by GitHub
parent 2d4625ad69
commit f56f391f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 26 deletions

View File

@ -33,7 +33,6 @@ from .const import (
CONF_ALLOW_BANDWIDTH_SENSORS,
CONF_ALLOW_UPTIME_SENSORS,
CONF_BLOCK_CLIENT,
CONF_CONTROLLER,
CONF_DETECTION_TIME,
CONF_DPI_RESTRICTIONS,
CONF_IGNORE_WIRED_BUG,
@ -152,8 +151,6 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
unique_id = user_input[CONF_SITE_ID]
self.config[CONF_SITE_ID] = self.site_ids[unique_id]
# Backwards compatible config
self.config[CONF_CONTROLLER] = self.config.copy()
config_entry = await self.async_set_unique_id(unique_id)
abort_reason = "configuration_updated"

View File

@ -14,7 +14,6 @@ PLATFORMS = [
Platform.UPDATE,
]
CONF_CONTROLLER = "controller"
CONF_SITE_ID = "site"
UNIFI_WIRELESS_CLIENTS = "unifi_wireless_clients"

View File

@ -11,11 +11,11 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import format_mac
from .const import CONF_CONTROLLER, DOMAIN as UNIFI_DOMAIN
from .const import DOMAIN as UNIFI_DOMAIN
from .controller import UniFiController
TO_REDACT = {CONF_CONTROLLER, CONF_PASSWORD}
REDACT_CONFIG = {CONF_CONTROLLER, CONF_HOST, CONF_PASSWORD, CONF_USERNAME}
TO_REDACT = {CONF_PASSWORD}
REDACT_CONFIG = {CONF_HOST, CONF_PASSWORD, CONF_USERNAME}
REDACT_CLIENTS = {"bssid", "essid"}
REDACT_DEVICES = {
"anon_id",

View File

@ -12,7 +12,6 @@ from homeassistant.components.unifi.const import (
CONF_ALLOW_BANDWIDTH_SENSORS,
CONF_ALLOW_UPTIME_SENSORS,
CONF_BLOCK_CLIENT,
CONF_CONTROLLER,
CONF_DETECTION_TIME,
CONF_DPI_RESTRICTIONS,
CONF_IGNORE_WIRED_BUG,
@ -143,14 +142,6 @@ async def test_flow_works(hass, aioclient_mock, mock_discovery):
CONF_PORT: 1234,
CONF_SITE_ID: "site_id",
CONF_VERIFY_SSL: True,
CONF_CONTROLLER: {
CONF_HOST: "1.2.3.4",
CONF_USERNAME: "username",
CONF_PASSWORD: "password",
CONF_PORT: 1234,
CONF_SITE_ID: "site_id",
CONF_VERIFY_SSL: True,
},
}

View File

@ -16,7 +16,6 @@ from homeassistant.components.device_tracker import DOMAIN as TRACKER_DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.components.unifi.const import (
CONF_CONTROLLER,
CONF_SITE_ID,
CONF_TRACK_CLIENTS,
CONF_TRACK_DEVICES,
@ -67,7 +66,7 @@ CONTROLLER_HOST = {
"uptime": 1562600160,
}
CONTROLLER_DATA = {
ENTRY_CONFIG = {
CONF_HOST: DEFAULT_HOST,
CONF_USERNAME: "username",
CONF_PASSWORD: "password",
@ -75,8 +74,6 @@ CONTROLLER_DATA = {
CONF_SITE_ID: DEFAULT_SITE,
CONF_VERIFY_SSL: False,
}
ENTRY_CONFIG = {**CONTROLLER_DATA, CONF_CONTROLLER: CONTROLLER_DATA}
ENTRY_OPTIONS = {}
CONFIGURATION = []
@ -227,8 +224,8 @@ async def test_controller_setup(hass, aioclient_mock):
assert forward_entry_setup.mock_calls[1][1] == (entry, SENSOR_DOMAIN)
assert forward_entry_setup.mock_calls[2][1] == (entry, SWITCH_DOMAIN)
assert controller.host == CONTROLLER_DATA[CONF_HOST]
assert controller.site == CONTROLLER_DATA[CONF_SITE_ID]
assert controller.host == ENTRY_CONFIG[CONF_HOST]
assert controller.site == ENTRY_CONFIG[CONF_SITE_ID]
assert controller.site_name == SITE[0]["desc"]
assert controller.site_role == SITE[0]["role"]
@ -467,12 +464,12 @@ async def test_get_unifi_controller(hass):
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", return_value=True
):
assert await get_unifi_controller(hass, CONTROLLER_DATA)
assert await get_unifi_controller(hass, ENTRY_CONFIG)
async def test_get_unifi_controller_verify_ssl_false(hass):
"""Successful call with verify ssl set to false."""
controller_data = dict(CONTROLLER_DATA)
controller_data = dict(ENTRY_CONFIG)
controller_data[CONF_VERIFY_SSL] = False
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", return_value=True
@ -500,4 +497,4 @@ async def test_get_unifi_controller_fails_to_connect(
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=side_effect
), pytest.raises(raised_exception):
await get_unifi_controller(hass, CONTROLLER_DATA)
await get_unifi_controller(hass, ENTRY_CONFIG)

View File

@ -29,6 +29,7 @@ async def test_entry_diagnostics(hass, hass_client, aioclient_mock):
"wired-tx_bytes": 5678000000,
}
device = {
"board_rev": "1.2.3",
"ethernet_table": [
{
"mac": "22:22:22:22:22:22",
@ -112,7 +113,6 @@ async def test_entry_diagnostics(hass, hass_client, aioclient_mock):
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
"config": {
"data": {
"controller": REDACTED,
"host": REDACTED,
"password": REDACTED,
"port": 1234,
@ -154,6 +154,7 @@ async def test_entry_diagnostics(hass, hass_client, aioclient_mock):
},
"devices": {
"00:00:00:00:00:01": {
"board_rev": "1.2.3",
"ethernet_table": [
{
"mac": "00:00:00:00:00:02",