Move mock_async_zeroconf to decorator in homekit tests (#119060)

This commit is contained in:
epenet
2024-06-07 12:30:02 +02:00
committed by GitHub
parent 81ee5fb46b
commit 549f66fd6f
5 changed files with 90 additions and 98 deletions

View File

@@ -15,7 +15,7 @@ from homeassistant.config_entries import SOURCE_IGNORE, SOURCE_IMPORT
from homeassistant.const import CONF_NAME, CONF_PORT, EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entityfilter import CONF_INCLUDE_DOMAINS
from homeassistant.setup import async_setup_component
@@ -405,13 +405,12 @@ async def test_options_flow_exclude_mode_basic(hass: HomeAssistant) -> None:
@patch(f"{PATH_HOMEKIT}.async_port_is_available", return_value=True)
@pytest.mark.usefixtures("mock_async_zeroconf")
async def test_options_flow_devices(
port_mock,
hass: HomeAssistant,
demo_cleanup,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
mock_async_zeroconf: None,
) -> None:
"""Test devices can be bridged."""
config_entry = MockConfigEntry(
@@ -502,8 +501,9 @@ async def test_options_flow_devices(
@patch(f"{PATH_HOMEKIT}.async_port_is_available", return_value=True)
@pytest.mark.usefixtures("mock_async_zeroconf")
async def test_options_flow_devices_preserved_when_advanced_off(
port_mock, hass: HomeAssistant, mock_async_zeroconf: None
port_mock, hass: HomeAssistant
) -> None:
"""Test devices are preserved if they were added in advanced mode but it was turned off."""
config_entry = MockConfigEntry(
@@ -1161,11 +1161,11 @@ async def test_options_flow_blocked_when_from_yaml(hass: HomeAssistant) -> None:
@patch(f"{PATH_HOMEKIT}.async_port_is_available", return_value=True)
@pytest.mark.usefixtures("mock_async_zeroconf")
async def test_options_flow_include_mode_basic_accessory(
port_mock,
hass: HomeAssistant,
hk_driver,
mock_async_zeroconf: None,
) -> None:
"""Test config flow options in include mode with a single accessory."""
config_entry = _mock_config_entry_with_options_populated()
@@ -1387,11 +1387,11 @@ def _get_schema_default(schema, key_name):
@patch(f"{PATH_HOMEKIT}.async_port_is_available", return_value=True)
@pytest.mark.usefixtures("mock_async_zeroconf")
async def test_options_flow_exclude_mode_skips_category_entities(
port_mock,
hass: HomeAssistant,
hk_driver,
mock_async_zeroconf: None,
entity_registry: er.EntityRegistry,
) -> None:
"""Ensure exclude mode does not offer category entities."""
@@ -1491,11 +1491,11 @@ async def test_options_flow_exclude_mode_skips_category_entities(
@patch(f"{PATH_HOMEKIT}.async_port_is_available", return_value=True)
@pytest.mark.usefixtures("mock_async_zeroconf")
async def test_options_flow_exclude_mode_skips_hidden_entities(
port_mock,
hass: HomeAssistant,
hk_driver,
mock_async_zeroconf: None,
entity_registry: er.EntityRegistry,
) -> None:
"""Ensure exclude mode does not offer hidden entities."""
@@ -1575,11 +1575,11 @@ async def test_options_flow_exclude_mode_skips_hidden_entities(
@patch(f"{PATH_HOMEKIT}.async_port_is_available", return_value=True)
@pytest.mark.usefixtures("mock_async_zeroconf")
async def test_options_flow_include_mode_allows_hidden_entities(
port_mock,
hass: HomeAssistant,
hk_driver,
mock_async_zeroconf: None,
entity_registry: er.EntityRegistry,
) -> None:
"""Ensure include mode does not offer hidden entities."""