Cleanup stale setup/import from Nuki (#62476)
* Cleanup stale setup/import from Nuki * Adjust testspull/62479/head
parent
d73081f875
commit
7cdfc7558e
|
@ -9,14 +9,7 @@ from pynuki.bridge import InvalidCredentialsException
|
|||
from requests.exceptions import RequestException
|
||||
|
||||
from homeassistant import exceptions
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PLATFORM,
|
||||
CONF_PORT,
|
||||
CONF_TOKEN,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN, Platform
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -28,7 +21,6 @@ from .const import (
|
|||
DATA_COORDINATOR,
|
||||
DATA_LOCKS,
|
||||
DATA_OPENERS,
|
||||
DEFAULT_PORT,
|
||||
DEFAULT_TIMEOUT,
|
||||
DOMAIN,
|
||||
ERROR_STATES,
|
||||
|
@ -56,31 +48,6 @@ def _update_devices(devices):
|
|||
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):
|
||||
"""Set up the Nuki entry."""
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ async def test_form(hass):
|
|||
"homeassistant.components.nuki.config_flow.NukiBridge.info",
|
||||
return_value=MOCK_INFO,
|
||||
), patch(
|
||||
"homeassistant.components.nuki.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"homeassistant.components.nuki.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
|
@ -47,7 +45,6 @@ async def test_form(hass):
|
|||
"port": 8080,
|
||||
"token": "test-token",
|
||||
}
|
||||
assert len(mock_setup.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",
|
||||
return_value=MOCK_INFO,
|
||||
), patch(
|
||||
"homeassistant.components.nuki.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"homeassistant.components.nuki.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
|
@ -182,7 +177,6 @@ async def test_dhcp_flow(hass):
|
|||
}
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
|
@ -212,7 +206,7 @@ async def test_reauth_success(hass):
|
|||
with patch(
|
||||
"homeassistant.components.nuki.config_flow.NukiBridge.info",
|
||||
return_value=MOCK_INFO,
|
||||
), patch("homeassistant.components.nuki.async_setup", return_value=True), patch(
|
||||
), patch(
|
||||
"homeassistant.components.nuki.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue