Bump zeroconf to 0.37.0 (#59932)

This commit is contained in:
J. Nick Koston 2021-11-18 22:23:20 -06:00 committed by GitHub
parent 4598353315
commit 347c4ea137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 106 additions and 60 deletions

View File

@ -2,7 +2,7 @@
"domain": "zeroconf",
"name": "Zero-configuration networking (zeroconf)",
"documentation": "https://www.home-assistant.io/integrations/zeroconf",
"requirements": ["zeroconf==0.36.13"],
"requirements": ["zeroconf==0.37.0"],
"dependencies": ["network", "api"],
"codeowners": ["@bdraco"],
"quality_scale": "internal",

View File

@ -33,7 +33,7 @@ sqlalchemy==1.4.26
voluptuous-serialize==2.4.0
voluptuous==0.12.2
yarl==1.6.3
zeroconf==0.36.13
zeroconf==0.37.0
pycryptodome>=3.6.6

View File

@ -2471,7 +2471,7 @@ youtube_dl==2021.06.06
zengge==0.2
# homeassistant.components.zeroconf
zeroconf==0.36.13
zeroconf==0.37.0
# homeassistant.components.zha
zha-quirks==0.0.63

View File

@ -1451,7 +1451,7 @@ yeelight==0.7.8
youless-api==0.15
# homeassistant.components.zeroconf
zeroconf==0.36.13
zeroconf==0.37.0
# homeassistant.components.zha
zha-quirks==0.0.63

View File

@ -0,0 +1,8 @@
"""bosch_shc session fixtures."""
import pytest
@pytest.fixture(autouse=True)
def bosch_shc_mock_async_zeroconf(mock_async_zeroconf):
"""Auto mock zeroconf."""

View File

@ -0,0 +1,8 @@
"""default_config session fixtures."""
import pytest
@pytest.fixture(autouse=True)
def default_config_mock_async_zeroconf(mock_async_zeroconf):
"""Auto mock zeroconf."""

View File

@ -31,3 +31,8 @@ def patch_mydevolo(request):
return_value=["1400000000000001", "1400000000000002"],
):
yield
@pytest.fixture(autouse=True)
def devolo_home_control_mock_async_zeroconf(mock_async_zeroconf):
"""Auto mock zeroconf."""

View File

@ -39,3 +39,8 @@ def mock_validate_input():
return_value=info,
):
yield info
@pytest.fixture(autouse=True)
def devolo_home_network_mock_async_zeroconf(mock_async_zeroconf):
"""Auto mock zeroconf."""

View File

@ -0,0 +1,8 @@
"""esphome session fixtures."""
import pytest
@pytest.fixture(autouse=True)
def esphome_mock_async_zeroconf(mock_async_zeroconf):
"""Auto mock zeroconf."""

View File

@ -362,7 +362,13 @@ async def test_options_flow_exclude_mode_basic(hass, mock_get_source_ip):
async def test_options_flow_devices(
mock_hap, hass, demo_cleanup, device_reg, entity_reg, mock_get_source_ip
mock_hap,
hass,
demo_cleanup,
device_reg,
entity_reg,
mock_get_source_ip,
mock_async_zeroconf,
):
"""Test devices can be bridged."""
config_entry = MockConfigEntry(
@ -441,7 +447,7 @@ async def test_options_flow_devices(
async def test_options_flow_devices_preserved_when_advanced_off(
mock_hap, hass, mock_get_source_ip
mock_hap, hass, mock_get_source_ip, mock_async_zeroconf
):
"""Test devices are preserved if they were added in advanced mode but it was turned off."""
config_entry = MockConfigEntry(

View File

@ -142,7 +142,7 @@ def _mock_pyhap_bridge():
)
async def test_setup_min(hass, mock_zeroconf):
async def test_setup_min(hass, mock_async_zeroconf):
"""Test async_setup with min config options."""
entry = MockConfigEntry(
@ -181,7 +181,7 @@ async def test_setup_min(hass, mock_zeroconf):
assert mock_homekit().async_start.called is True
async def test_homekit_setup(hass, hk_driver, mock_zeroconf):
async def test_homekit_setup(hass, hk_driver, mock_async_zeroconf):
"""Test setup of bridge and driver."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -226,7 +226,7 @@ async def test_homekit_setup(hass, hk_driver, mock_zeroconf):
assert homekit.driver.safe_mode is False
async def test_homekit_setup_ip_address(hass, hk_driver, mock_zeroconf):
async def test_homekit_setup_ip_address(hass, hk_driver, mock_async_zeroconf):
"""Test setup with given IP address."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -247,11 +247,10 @@ async def test_homekit_setup_ip_address(hass, hk_driver, mock_zeroconf):
entry_title=entry.title,
)
mock_zeroconf = MagicMock()
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
uuid = await hass.helpers.instance_id.async_get()
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
await hass.async_add_executor_job(homekit.setup, mock_zeroconf, uuid)
await hass.async_add_executor_job(homekit.setup, mock_async_zeroconf, uuid)
mock_driver.assert_called_with(
hass,
entry.entry_id,
@ -262,12 +261,12 @@ async def test_homekit_setup_ip_address(hass, hk_driver, mock_zeroconf):
port=DEFAULT_PORT,
persist_file=path,
advertised_address=None,
async_zeroconf_instance=mock_zeroconf,
async_zeroconf_instance=mock_async_zeroconf,
zeroconf_server=f"{uuid}-hap.local.",
)
async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_zeroconf):
async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_async_zeroconf):
"""Test setup with given IP address to advertise."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -308,7 +307,7 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_zeroconf):
)
async def test_homekit_add_accessory(hass, mock_zeroconf):
async def test_homekit_add_accessory(hass, mock_async_zeroconf):
"""Add accessory if config exists and get_acc returns an accessory."""
entry = MockConfigEntry(
@ -345,7 +344,7 @@ async def test_homekit_add_accessory(hass, mock_zeroconf):
@pytest.mark.parametrize("acc_category", [CATEGORY_TELEVISION, CATEGORY_CAMERA])
async def test_homekit_warn_add_accessory_bridge(
hass, acc_category, mock_zeroconf, caplog
hass, acc_category, mock_async_zeroconf, caplog
):
"""Test we warn when adding cameras or tvs to a bridge."""
@ -373,7 +372,7 @@ async def test_homekit_warn_add_accessory_bridge(
assert "accessory mode" in caplog.text
async def test_homekit_remove_accessory(hass, mock_zeroconf):
async def test_homekit_remove_accessory(hass, mock_async_zeroconf):
"""Remove accessory from bridge."""
entry = await async_init_integration(hass)
@ -391,7 +390,7 @@ async def test_homekit_remove_accessory(hass, mock_zeroconf):
assert len(homekit.bridge.accessories) == 0
async def test_homekit_entity_filter(hass, mock_zeroconf):
async def test_homekit_entity_filter(hass, mock_async_zeroconf):
"""Test the entity filter."""
entry = await async_init_integration(hass)
@ -410,7 +409,7 @@ async def test_homekit_entity_filter(hass, mock_zeroconf):
assert hass.states.get("light.demo") not in filtered_states
async def test_homekit_entity_glob_filter(hass, mock_zeroconf):
async def test_homekit_entity_glob_filter(hass, mock_async_zeroconf):
"""Test the entity filter."""
entry = await async_init_integration(hass)
@ -434,7 +433,7 @@ async def test_homekit_entity_glob_filter(hass, mock_zeroconf):
assert hass.states.get("light.included_test") in filtered_states
async def test_homekit_start(hass, hk_driver, mock_zeroconf, device_reg):
async def test_homekit_start(hass, hk_driver, mock_async_zeroconf, device_reg):
"""Test HomeKit start method."""
entry = await async_init_integration(hass)
@ -509,7 +508,9 @@ async def test_homekit_start(hass, hk_driver, mock_zeroconf, device_reg):
assert homekit.driver.state.config_version == 1
async def test_homekit_start_with_a_broken_accessory(hass, hk_driver, mock_zeroconf):
async def test_homekit_start_with_a_broken_accessory(
hass, hk_driver, mock_async_zeroconf
):
"""Test HomeKit start method."""
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
@ -549,7 +550,7 @@ async def test_homekit_start_with_a_broken_accessory(hass, hk_driver, mock_zeroc
async def test_homekit_start_with_a_device(
hass, hk_driver, mock_zeroconf, demo_cleanup, device_reg, entity_reg
hass, hk_driver, mock_async_zeroconf, demo_cleanup, device_reg, entity_reg
):
"""Test HomeKit start method with a device."""
@ -611,7 +612,7 @@ async def test_homekit_stop(hass):
assert homekit.driver.async_stop.called is True
async def test_homekit_reset_accessories(hass, mock_zeroconf):
async def test_homekit_reset_accessories(hass, mock_async_zeroconf):
"""Test resetting HomeKit accessories."""
entry = MockConfigEntry(
@ -656,7 +657,7 @@ async def test_homekit_reset_accessories(hass, mock_zeroconf):
homekit.status = STATUS_READY
async def test_homekit_unpair(hass, device_reg, mock_zeroconf):
async def test_homekit_unpair(hass, device_reg, mock_async_zeroconf):
"""Test unpairing HomeKit accessories."""
entry = MockConfigEntry(
@ -698,7 +699,7 @@ async def test_homekit_unpair(hass, device_reg, mock_zeroconf):
homekit.status = STATUS_STOPPED
async def test_homekit_unpair_missing_device_id(hass, device_reg, mock_zeroconf):
async def test_homekit_unpair_missing_device_id(hass, device_reg, mock_async_zeroconf):
"""Test unpairing HomeKit accessories with invalid device id."""
entry = MockConfigEntry(
@ -736,7 +737,7 @@ async def test_homekit_unpair_missing_device_id(hass, device_reg, mock_zeroconf)
homekit.status = STATUS_STOPPED
async def test_homekit_unpair_not_homekit_device(hass, device_reg, mock_zeroconf):
async def test_homekit_unpair_not_homekit_device(hass, device_reg, mock_async_zeroconf):
"""Test unpairing HomeKit accessories with a non-homekit device id."""
entry = MockConfigEntry(
@ -784,7 +785,7 @@ async def test_homekit_unpair_not_homekit_device(hass, device_reg, mock_zeroconf
homekit.status = STATUS_STOPPED
async def test_homekit_reset_accessories_not_supported(hass, mock_zeroconf):
async def test_homekit_reset_accessories_not_supported(hass, mock_async_zeroconf):
"""Test resetting HomeKit accessories with an unsupported entity."""
entry = MockConfigEntry(
@ -828,7 +829,7 @@ async def test_homekit_reset_accessories_not_supported(hass, mock_zeroconf):
homekit.status = STATUS_STOPPED
async def test_homekit_reset_accessories_state_missing(hass, mock_zeroconf):
async def test_homekit_reset_accessories_state_missing(hass, mock_async_zeroconf):
"""Test resetting HomeKit accessories when the state goes missing."""
entry = MockConfigEntry(
@ -870,7 +871,7 @@ async def test_homekit_reset_accessories_state_missing(hass, mock_zeroconf):
homekit.status = STATUS_STOPPED
async def test_homekit_reset_accessories_not_bridged(hass, mock_zeroconf):
async def test_homekit_reset_accessories_not_bridged(hass, mock_async_zeroconf):
"""Test resetting HomeKit accessories when the state is not bridged."""
entry = MockConfigEntry(
@ -912,7 +913,7 @@ async def test_homekit_reset_accessories_not_bridged(hass, mock_zeroconf):
homekit.status = STATUS_STOPPED
async def test_homekit_reset_single_accessory(hass, mock_zeroconf):
async def test_homekit_reset_single_accessory(hass, mock_async_zeroconf):
"""Test resetting HomeKit single accessory."""
entry = MockConfigEntry(
@ -951,7 +952,7 @@ async def test_homekit_reset_single_accessory(hass, mock_zeroconf):
homekit.status = STATUS_READY
async def test_homekit_reset_single_accessory_unsupported(hass, mock_zeroconf):
async def test_homekit_reset_single_accessory_unsupported(hass, mock_async_zeroconf):
"""Test resetting HomeKit single accessory with an unsupported entity."""
entry = MockConfigEntry(
@ -988,7 +989,7 @@ async def test_homekit_reset_single_accessory_unsupported(hass, mock_zeroconf):
homekit.status = STATUS_STOPPED
async def test_homekit_reset_single_accessory_state_missing(hass, mock_zeroconf):
async def test_homekit_reset_single_accessory_state_missing(hass, mock_async_zeroconf):
"""Test resetting HomeKit single accessory when the state goes missing."""
entry = MockConfigEntry(
@ -1024,7 +1025,7 @@ async def test_homekit_reset_single_accessory_state_missing(hass, mock_zeroconf)
homekit.status = STATUS_STOPPED
async def test_homekit_reset_single_accessory_no_match(hass, mock_zeroconf):
async def test_homekit_reset_single_accessory_no_match(hass, mock_async_zeroconf):
"""Test resetting HomeKit single accessory when the entity id does not match."""
entry = MockConfigEntry(
@ -1060,7 +1061,9 @@ async def test_homekit_reset_single_accessory_no_match(hass, mock_zeroconf):
homekit.status = STATUS_STOPPED
async def test_homekit_too_many_accessories(hass, hk_driver, caplog, mock_zeroconf):
async def test_homekit_too_many_accessories(
hass, hk_driver, caplog, mock_async_zeroconf
):
"""Test adding too many accessories to HomeKit."""
entry = await async_init_integration(hass)
@ -1090,7 +1093,7 @@ async def test_homekit_too_many_accessories(hass, hk_driver, caplog, mock_zeroco
async def test_homekit_finds_linked_batteries(
hass, hk_driver, device_reg, entity_reg, mock_zeroconf
hass, hk_driver, device_reg, entity_reg, mock_async_zeroconf
):
"""Test HomeKit start method."""
entry = await async_init_integration(hass)
@ -1161,7 +1164,7 @@ async def test_homekit_finds_linked_batteries(
async def test_homekit_async_get_integration_fails(
hass, hk_driver, device_reg, entity_reg, mock_zeroconf
hass, hk_driver, device_reg, entity_reg, mock_async_zeroconf
):
"""Test that we continue if async_get_integration fails."""
entry = await async_init_integration(hass)
@ -1230,7 +1233,7 @@ async def test_homekit_async_get_integration_fails(
)
async def test_yaml_updates_update_config_entry_for_name(hass, mock_zeroconf):
async def test_yaml_updates_update_config_entry_for_name(hass, mock_async_zeroconf):
"""Test async_setup with imported config."""
entry = MockConfigEntry(
@ -1274,7 +1277,7 @@ async def test_yaml_updates_update_config_entry_for_name(hass, mock_zeroconf):
mock_homekit().async_start.assert_called()
async def test_homekit_uses_system_zeroconf(hass, hk_driver, mock_zeroconf):
async def test_homekit_uses_system_zeroconf(hass, hk_driver, mock_async_zeroconf):
"""Test HomeKit uses system zeroconf."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -1306,7 +1309,7 @@ def _write_data(path: str, data: dict) -> None:
async def test_homekit_ignored_missing_devices(
hass, hk_driver, device_reg, entity_reg, mock_zeroconf
hass, hk_driver, device_reg, entity_reg, mock_async_zeroconf
):
"""Test HomeKit handles a device in the entity registry but missing from the device registry."""
@ -1376,7 +1379,7 @@ async def test_homekit_ignored_missing_devices(
async def test_homekit_finds_linked_motion_sensors(
hass, hk_driver, device_reg, entity_reg, mock_zeroconf
hass, hk_driver, device_reg, entity_reg, mock_async_zeroconf
):
"""Test HomeKit start method."""
entry = await async_init_integration(hass)
@ -1438,7 +1441,7 @@ async def test_homekit_finds_linked_motion_sensors(
async def test_homekit_finds_linked_humidity_sensors(
hass, hk_driver, device_reg, entity_reg, mock_zeroconf
hass, hk_driver, device_reg, entity_reg, mock_async_zeroconf
):
"""Test HomeKit start method."""
entry = await async_init_integration(hass)
@ -1502,7 +1505,7 @@ async def test_homekit_finds_linked_humidity_sensors(
)
async def test_reload(hass, mock_zeroconf):
async def test_reload(hass, mock_async_zeroconf):
"""Test we can reload from yaml."""
entry = MockConfigEntry(
@ -1574,7 +1577,7 @@ async def test_reload(hass, mock_zeroconf):
async def test_homekit_start_in_accessory_mode(
hass, hk_driver, mock_zeroconf, device_reg
hass, hk_driver, mock_async_zeroconf, device_reg
):
"""Test HomeKit start method in accessory mode."""
entry = await async_init_integration(hass)
@ -1605,7 +1608,7 @@ async def test_homekit_start_in_accessory_mode(
async def test_homekit_start_in_accessory_mode_unsupported_entity(
hass, hk_driver, mock_zeroconf, device_reg, caplog
hass, hk_driver, mock_async_zeroconf, device_reg, caplog
):
"""Test HomeKit start method in accessory mode with an unsupported entity."""
entry = await async_init_integration(hass)
@ -1635,7 +1638,7 @@ async def test_homekit_start_in_accessory_mode_unsupported_entity(
async def test_homekit_start_in_accessory_mode_missing_entity(
hass, hk_driver, mock_zeroconf, device_reg, caplog
hass, hk_driver, mock_async_zeroconf, device_reg, caplog
):
"""Test HomeKit start method in accessory mode when entity is not available."""
entry = await async_init_integration(hass)
@ -1659,7 +1662,7 @@ async def test_homekit_start_in_accessory_mode_missing_entity(
assert "entity not available" in caplog.text
async def test_wait_for_port_to_free(hass, hk_driver, mock_zeroconf, caplog):
async def test_wait_for_port_to_free(hass, hk_driver, mock_async_zeroconf, caplog):
"""Test we wait for the port to free before declaring unload success."""
entry = MockConfigEntry(

View File

@ -30,5 +30,5 @@ def controller(hass):
@pytest.fixture(autouse=True)
def homekit_mock_zeroconf(mock_zeroconf):
"""Mock zeroconf in all homekit tests."""
def hk_mock_async_zeroconf(mock_async_zeroconf):
"""Auto mock zeroconf."""

View File

@ -1,5 +1,4 @@
"""Tests for the Zeroconf component."""
from unittest.mock import AsyncMock, patch
import pytest
@ -8,14 +7,3 @@ import pytest
def zc_mock_get_source_ip(mock_get_source_ip):
"""Enable the mock_get_source_ip fixture for all zeroconf tests."""
return mock_get_source_ip
@pytest.fixture
def mock_async_zeroconf(mock_zeroconf):
"""Mock AsyncZeroconf."""
with patch("homeassistant.components.zeroconf.HaAsyncZeroconf") as mock_aiozc:
zc = mock_aiozc.return_value
zc.async_register_service = AsyncMock()
zc.zeroconf.async_wait_for_start = AsyncMock()
zc.ha_async_close = AsyncMock()
yield zc

View File

@ -6,7 +6,7 @@ import logging
import socket
import ssl
import threading
from unittest.mock import MagicMock, patch
from unittest.mock import AsyncMock, MagicMock, patch
from aiohttp.test_utils import make_mocked_request
import freezegun
@ -617,6 +617,21 @@ def mock_zeroconf():
yield
@pytest.fixture
def mock_async_zeroconf(mock_zeroconf):
"""Mock AsyncZeroconf."""
with patch("homeassistant.components.zeroconf.HaAsyncZeroconf") as mock_aiozc:
zc = mock_aiozc.return_value
zc.async_unregister_service = AsyncMock()
zc.async_register_service = AsyncMock()
zc.async_update_service = AsyncMock()
zc.zeroconf.async_wait_for_start = AsyncMock()
zc.zeroconf.done = False
zc.async_close = AsyncMock()
zc.ha_async_close = AsyncMock()
yield zc
@pytest.fixture
def legacy_patchable_time():
"""Allow time to be patchable by using event listeners instead of asyncio loop."""