Cleanup stale setup/import from Nuki (#62476)

* Cleanup stale setup/import from Nuki

* Adjust tests
This commit is contained in:
Franck Nijhof 2021-12-21 10:31:41 +01:00 committed by GitHub
parent d73081f875
commit 7cdfc7558e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 41 deletions

View File

@ -9,14 +9,7 @@ from pynuki.bridge import InvalidCredentialsException
from requests.exceptions import RequestException from requests.exceptions import RequestException
from homeassistant import exceptions from homeassistant import exceptions
from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN, Platform
from homeassistant.const import (
CONF_HOST,
CONF_PLATFORM,
CONF_PORT,
CONF_TOKEN,
Platform,
)
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -28,7 +21,6 @@ from .const import (
DATA_COORDINATOR, DATA_COORDINATOR,
DATA_LOCKS, DATA_LOCKS,
DATA_OPENERS, DATA_OPENERS,
DEFAULT_PORT,
DEFAULT_TIMEOUT, DEFAULT_TIMEOUT,
DOMAIN, DOMAIN,
ERROR_STATES, ERROR_STATES,
@ -56,31 +48,6 @@ def _update_devices(devices):
break break
async def async_setup(hass, config):
"""Set up the Nuki component."""
hass.data.setdefault(DOMAIN, {})
for platform in PLATFORMS:
if (confs := config.get(platform)) is None:
continue
for conf in confs:
if CONF_PLATFORM in conf and conf[CONF_PLATFORM] == DOMAIN:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_HOST: conf[CONF_HOST],
CONF_PORT: conf.get(CONF_PORT, DEFAULT_PORT),
CONF_TOKEN: conf[CONF_TOKEN],
},
)
)
return True
async def async_setup_entry(hass, entry): async def async_setup_entry(hass, entry):
"""Set up the Nuki entry.""" """Set up the Nuki entry."""

View File

@ -25,8 +25,6 @@ async def test_form(hass):
"homeassistant.components.nuki.config_flow.NukiBridge.info", "homeassistant.components.nuki.config_flow.NukiBridge.info",
return_value=MOCK_INFO, return_value=MOCK_INFO,
), patch( ), patch(
"homeassistant.components.nuki.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.nuki.async_setup_entry", "homeassistant.components.nuki.async_setup_entry",
return_value=True, return_value=True,
) as mock_setup_entry: ) as mock_setup_entry:
@ -47,7 +45,6 @@ async def test_form(hass):
"port": 8080, "port": 8080,
"token": "test-token", "token": "test-token",
} }
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -159,8 +156,6 @@ async def test_dhcp_flow(hass):
"homeassistant.components.nuki.config_flow.NukiBridge.info", "homeassistant.components.nuki.config_flow.NukiBridge.info",
return_value=MOCK_INFO, return_value=MOCK_INFO,
), patch( ), patch(
"homeassistant.components.nuki.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.nuki.async_setup_entry", "homeassistant.components.nuki.async_setup_entry",
return_value=True, return_value=True,
) as mock_setup_entry: ) as mock_setup_entry:
@ -182,7 +177,6 @@ async def test_dhcp_flow(hass):
} }
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -212,7 +206,7 @@ async def test_reauth_success(hass):
with patch( with patch(
"homeassistant.components.nuki.config_flow.NukiBridge.info", "homeassistant.components.nuki.config_flow.NukiBridge.info",
return_value=MOCK_INFO, return_value=MOCK_INFO,
), patch("homeassistant.components.nuki.async_setup", return_value=True), patch( ), patch(
"homeassistant.components.nuki.async_setup_entry", "homeassistant.components.nuki.async_setup_entry",
return_value=True, return_value=True,
): ):