mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Move imports to top for homekit (#29560)
* Move imports to top for homekit * Moved back a couple imports, added annotation to disable import-outside-toplevel * Fix all tests in test_homekit.py
This commit is contained in:
parent
bb3fa6990a
commit
72f336a2dd
@ -29,6 +29,7 @@ from homeassistant.helpers.entityfilter import FILTER_SCHEMA
|
||||
from homeassistant.util import get_local_ip
|
||||
from homeassistant.util.decorator import Registry
|
||||
|
||||
from .accessories import HomeBridge, HomeDriver
|
||||
from .const import (
|
||||
BRIDGE_NAME,
|
||||
CONF_ADVERTISE_IP,
|
||||
@ -302,7 +303,6 @@ class HomeKit:
|
||||
|
||||
def setup(self):
|
||||
"""Set up bridge and accessory driver."""
|
||||
from .accessories import HomeBridge, HomeDriver
|
||||
|
||||
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.stop)
|
||||
|
||||
@ -361,7 +361,7 @@ class HomeKit:
|
||||
return
|
||||
self.status = STATUS_WAIT
|
||||
|
||||
from . import ( # noqa: F401 pylint: disable=unused-import
|
||||
from . import ( # noqa: F401 pylint: disable=unused-import, import-outside-toplevel
|
||||
type_covers,
|
||||
type_fans,
|
||||
type_lights,
|
||||
|
@ -126,7 +126,7 @@ async def test_homekit_setup(hass, hk_driver):
|
||||
homekit = HomeKit(hass, BRIDGE_NAME, DEFAULT_PORT, None, {}, {}, DEFAULT_SAFE_MODE)
|
||||
|
||||
with patch(
|
||||
PATH_HOMEKIT + ".accessories.HomeDriver", return_value=hk_driver
|
||||
PATH_HOMEKIT + ".HomeDriver", return_value=hk_driver
|
||||
) as mock_driver, patch("homeassistant.util.get_local_ip") as mock_ip:
|
||||
mock_ip.return_value = IP_ADDRESS
|
||||
await hass.async_add_job(homekit.setup)
|
||||
@ -150,9 +150,7 @@ async def test_homekit_setup_ip_address(hass, hk_driver):
|
||||
"""Test setup with given IP address."""
|
||||
homekit = HomeKit(hass, BRIDGE_NAME, DEFAULT_PORT, "172.0.0.0", {}, {}, None)
|
||||
|
||||
with patch(
|
||||
PATH_HOMEKIT + ".accessories.HomeDriver", return_value=hk_driver
|
||||
) as mock_driver:
|
||||
with patch(PATH_HOMEKIT + ".HomeDriver", return_value=hk_driver) as mock_driver:
|
||||
await hass.async_add_job(homekit.setup)
|
||||
mock_driver.assert_called_with(
|
||||
hass,
|
||||
@ -169,9 +167,7 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver):
|
||||
hass, BRIDGE_NAME, DEFAULT_PORT, "0.0.0.0", {}, {}, None, "192.168.1.100"
|
||||
)
|
||||
|
||||
with patch(
|
||||
PATH_HOMEKIT + ".accessories.HomeDriver", return_value=hk_driver
|
||||
) as mock_driver:
|
||||
with patch(PATH_HOMEKIT + ".HomeDriver", return_value=hk_driver) as mock_driver:
|
||||
await hass.async_add_job(homekit.setup)
|
||||
mock_driver.assert_called_with(
|
||||
hass,
|
||||
@ -186,7 +182,7 @@ async def test_homekit_setup_safe_mode(hass, hk_driver):
|
||||
"""Test if safe_mode flag is set."""
|
||||
homekit = HomeKit(hass, BRIDGE_NAME, DEFAULT_PORT, None, {}, {}, True)
|
||||
|
||||
with patch(PATH_HOMEKIT + ".accessories.HomeDriver", return_value=hk_driver):
|
||||
with patch(PATH_HOMEKIT + ".HomeDriver", return_value=hk_driver):
|
||||
await hass.async_add_job(homekit.setup)
|
||||
assert homekit.driver.safe_mode is True
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user