Mock out network.util.async_get_source_ip in tests (#55592)

This commit is contained in:
Erik Montnemery 2021-09-02 20:44:50 +02:00 committed by GitHub
parent 363320eedb
commit 7dbe8070f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 159 additions and 80 deletions

View file

@ -102,6 +102,13 @@ def always_patch_driver(hk_driver):
"""Load the hk_driver fixture."""
@pytest.fixture(autouse=True)
def patch_source_ip(mock_get_source_ip):
"""Patch homeassistant and pyhap functions for getting local address."""
with patch("pyhap.util.get_local_address", return_value="10.10.10.10"):
yield
def _mock_homekit(hass, entry, homekit_mode, entity_filter=None, devices=None):
return HomeKit(
hass=hass,
@ -1301,7 +1308,7 @@ async def test_homekit_uses_system_zeroconf(hass, hk_driver, mock_zeroconf):
with patch("pyhap.accessory_driver.AccessoryDriver.async_start"), patch(
f"{PATH_HOMEKIT}.HomeKit.async_stop"
):
), patch(f"{PATH_HOMEKIT}.port_is_available"):
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()