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
2 changed files with 6 additions and 10 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue