mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix manual specification of multiple advertise_ip with HomeKit (#95548)
fixes #95508
This commit is contained in:
parent
8e00bd4436
commit
e3e1bef376
@ -168,7 +168,7 @@ BRIDGE_SCHEMA = vol.All(
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_IP_ADDRESS): vol.All(ipaddress.ip_address, cv.string),
|
||||
vol.Optional(CONF_ADVERTISE_IP): vol.All(
|
||||
cv.ensure_list, ipaddress.ip_address, cv.string
|
||||
cv.ensure_list, [ipaddress.ip_address], [cv.string]
|
||||
),
|
||||
vol.Optional(CONF_FILTER, default={}): BASE_FILTER_SCHEMA,
|
||||
vol.Optional(CONF_ENTITY_CONFIG, default={}): validate_entity_config,
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
from unittest.mock import ANY, AsyncMock, MagicMock, Mock, patch
|
||||
from uuid import uuid1
|
||||
|
||||
@ -24,6 +25,7 @@ from homeassistant.components.homekit.accessories import HomeBridge
|
||||
from homeassistant.components.homekit.const import (
|
||||
BRIDGE_NAME,
|
||||
BRIDGE_SERIAL_NUMBER,
|
||||
CONF_ADVERTISE_IP,
|
||||
DEFAULT_PORT,
|
||||
DOMAIN,
|
||||
HOMEKIT,
|
||||
@ -322,6 +324,80 @@ async def test_homekit_setup_ip_address(
|
||||
)
|
||||
|
||||
|
||||
async def test_homekit_with_single_advertise_ips(
|
||||
hass: HomeAssistant,
|
||||
hk_driver,
|
||||
mock_async_zeroconf: None,
|
||||
hass_storage: dict[str, Any],
|
||||
) -> None:
|
||||
"""Test setup with a single advertise ips."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={CONF_NAME: "mock_name", CONF_PORT: 12345, CONF_ADVERTISE_IP: "1.3.4.4"},
|
||||
source=SOURCE_IMPORT,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
||||
mock_driver.async_start = AsyncMock()
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
mock_driver.assert_called_with(
|
||||
hass,
|
||||
entry.entry_id,
|
||||
ANY,
|
||||
entry.title,
|
||||
loop=hass.loop,
|
||||
address=[None],
|
||||
port=ANY,
|
||||
persist_file=ANY,
|
||||
advertised_address="1.3.4.4",
|
||||
async_zeroconf_instance=mock_async_zeroconf,
|
||||
zeroconf_server=ANY,
|
||||
loader=ANY,
|
||||
iid_storage=ANY,
|
||||
)
|
||||
|
||||
|
||||
async def test_homekit_with_many_advertise_ips(
|
||||
hass: HomeAssistant,
|
||||
hk_driver,
|
||||
mock_async_zeroconf: None,
|
||||
hass_storage: dict[str, Any],
|
||||
) -> None:
|
||||
"""Test setup with many advertise ips."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_NAME: "mock_name",
|
||||
CONF_PORT: 12345,
|
||||
CONF_ADVERTISE_IP: ["1.3.4.4", "4.3.2.2"],
|
||||
},
|
||||
source=SOURCE_IMPORT,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
||||
mock_driver.async_start = AsyncMock()
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
mock_driver.assert_called_with(
|
||||
hass,
|
||||
entry.entry_id,
|
||||
ANY,
|
||||
entry.title,
|
||||
loop=hass.loop,
|
||||
address=[None],
|
||||
port=ANY,
|
||||
persist_file=ANY,
|
||||
advertised_address=["1.3.4.4", "4.3.2.2"],
|
||||
async_zeroconf_instance=mock_async_zeroconf,
|
||||
zeroconf_server=ANY,
|
||||
loader=ANY,
|
||||
iid_storage=ANY,
|
||||
)
|
||||
|
||||
|
||||
async def test_homekit_setup_advertise_ips(
|
||||
hass: HomeAssistant, hk_driver, mock_async_zeroconf: None
|
||||
) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user