Use new ServiceInfo location in component tests (part 1) (#136057)
parent
760168de83
commit
64500e837f
|
@ -2,7 +2,6 @@
|
|||
|
||||
from samsungtvws.event import ED_INSTALLED_APP_EVENT
|
||||
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.samsungtv.const import (
|
||||
CONF_SESSION_ID,
|
||||
METHOD_LEGACY,
|
||||
|
@ -23,6 +22,7 @@ from homeassistant.helpers.service_info.ssdp import (
|
|||
ATTR_UPNP_MANUFACTURER,
|
||||
ATTR_UPNP_MODEL_NAME,
|
||||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
MOCK_CONFIG = {
|
||||
|
@ -61,7 +61,7 @@ MOCK_ENTRY_WS_WITH_MAC = {
|
|||
CONF_TOKEN: "123456789",
|
||||
}
|
||||
|
||||
MOCK_SSDP_DATA_RENDERING_CONTROL_ST = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DATA_RENDERING_CONTROL_ST = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="urn:schemas-upnp-org:service:RenderingControl:1",
|
||||
ssdp_location="https://fake_host:12345/test",
|
||||
|
@ -72,7 +72,7 @@ MOCK_SSDP_DATA_RENDERING_CONTROL_ST = ssdp.SsdpServiceInfo(
|
|||
ATTR_UPNP_UDN: "uuid:0d1cef00-00dc-1000-9c80-4844f7b172de",
|
||||
},
|
||||
)
|
||||
MOCK_SSDP_DATA_MAIN_TV_AGENT_ST = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DATA_MAIN_TV_AGENT_ST = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="urn:samsung.com:service:MainTVAgent2:1",
|
||||
ssdp_location="https://fake_host:12345/tv_agent",
|
||||
|
|
|
@ -17,7 +17,6 @@ from websockets import frames
|
|||
from websockets.exceptions import ConnectionClosedError, WebSocketException
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp, ssdp, zeroconf
|
||||
from homeassistant.components.samsungtv.config_flow import SamsungTVConfigFlow
|
||||
from homeassistant.components.samsungtv.const import (
|
||||
CONF_MANUFACTURER,
|
||||
|
@ -47,6 +46,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import BaseServiceInfo, FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_FRIENDLY_NAME,
|
||||
ATTR_UPNP_MANUFACTURER,
|
||||
|
@ -54,6 +54,7 @@ from homeassistant.helpers.service_info.ssdp import (
|
|||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .const import (
|
||||
|
@ -83,7 +84,7 @@ MOCK_IMPORT_WSDATA = {
|
|||
CONF_PORT: 8002,
|
||||
}
|
||||
MOCK_USER_DATA = {CONF_HOST: "fake_host", CONF_NAME: "fake_name"}
|
||||
MOCK_SSDP_DATA = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DATA = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="https://fake_host:12345/test",
|
||||
|
@ -94,7 +95,7 @@ MOCK_SSDP_DATA = ssdp.SsdpServiceInfo(
|
|||
ATTR_UPNP_UDN: "uuid:0d1cef00-00dc-1000-9c80-4844f7b172de",
|
||||
},
|
||||
)
|
||||
MOCK_SSDP_DATA_NO_MANUFACTURER = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DATA_NO_MANUFACTURER = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="https://fake_host:12345/test",
|
||||
|
@ -104,7 +105,7 @@ MOCK_SSDP_DATA_NO_MANUFACTURER = ssdp.SsdpServiceInfo(
|
|||
},
|
||||
)
|
||||
|
||||
MOCK_SSDP_DATA_NOPREFIX = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DATA_NOPREFIX = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://fake2_host:12345/test",
|
||||
|
@ -115,7 +116,7 @@ MOCK_SSDP_DATA_NOPREFIX = ssdp.SsdpServiceInfo(
|
|||
ATTR_UPNP_UDN: "uuid:0d1cef00-00dc-1000-9c80-4844f7b172df",
|
||||
},
|
||||
)
|
||||
MOCK_SSDP_DATA_WRONGMODEL = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DATA_WRONGMODEL = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://fake2_host:12345/test",
|
||||
|
@ -126,11 +127,11 @@ MOCK_SSDP_DATA_WRONGMODEL = ssdp.SsdpServiceInfo(
|
|||
ATTR_UPNP_UDN: "uuid:0d1cef00-00dc-1000-9c80-4844f7b172df",
|
||||
},
|
||||
)
|
||||
MOCK_DHCP_DATA = dhcp.DhcpServiceInfo(
|
||||
MOCK_DHCP_DATA = DhcpServiceInfo(
|
||||
ip="fake_host", macaddress="aabbccddeeff", hostname="fake_hostname"
|
||||
)
|
||||
EXISTING_IP = "192.168.40.221"
|
||||
MOCK_ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo(
|
||||
MOCK_ZEROCONF_DATA = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
hostname="mock_hostname",
|
||||
|
@ -1704,7 +1705,7 @@ async def test_update_legacy_missing_mac_from_dhcp(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=EXISTING_IP, macaddress="aabbccddeeff", hostname="fake_hostname"
|
||||
),
|
||||
)
|
||||
|
@ -1741,7 +1742,7 @@ async def test_update_legacy_missing_mac_from_dhcp_no_unique_id(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=EXISTING_IP, macaddress="aabbccddeeff", hostname="fake_hostname"
|
||||
),
|
||||
)
|
||||
|
|
|
@ -12,7 +12,6 @@ from screenlogicpy.const.common import (
|
|||
)
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.screenlogic.config_flow import (
|
||||
GATEWAY_MANUAL_ENTRY,
|
||||
GATEWAY_SELECT_KEY,
|
||||
|
@ -25,6 +24,7 @@ from homeassistant.components.screenlogic.const import (
|
|||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -135,7 +135,7 @@ async def test_dhcp(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="Pentair: 01-01-01",
|
||||
ip="1.1.1.1",
|
||||
macaddress="aabbccddeeff",
|
||||
|
|
|
@ -15,7 +15,6 @@ from aioshelly.exceptions import (
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.shelly import MacAddressMismatchError, config_flow
|
||||
from homeassistant.components.shelly.const import (
|
||||
CONF_BLE_SCANNER_MODE,
|
||||
|
@ -25,6 +24,10 @@ from homeassistant.components.shelly.const import (
|
|||
from homeassistant.components.shelly.coordinator import ENTRY_RELOAD_COOLDOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import (
|
||||
ATTR_PROPERTIES_ID,
|
||||
ZeroconfServiceInfo,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
|
@ -33,22 +36,22 @@ from . import init_integration
|
|||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
DISCOVERY_INFO = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.1.1.1"),
|
||||
ip_addresses=[ip_address("1.1.1.1")],
|
||||
hostname="mock_hostname",
|
||||
name="shelly1pm-12345",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "shelly1pm-12345"},
|
||||
properties={ATTR_PROPERTIES_ID: "shelly1pm-12345"},
|
||||
type="mock_type",
|
||||
)
|
||||
DISCOVERY_INFO_WITH_MAC = zeroconf.ZeroconfServiceInfo(
|
||||
DISCOVERY_INFO_WITH_MAC = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.1.1.1"),
|
||||
ip_addresses=[ip_address("1.1.1.1")],
|
||||
hostname="mock_hostname",
|
||||
name="shelly1pm-AABBCCDDEEFF",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "shelly1pm-AABBCCDDEEFF"},
|
||||
properties={ATTR_PROPERTIES_ID: "shelly1pm-AABBCCDDEEFF"},
|
||||
type="mock_type",
|
||||
)
|
||||
|
||||
|
@ -1459,13 +1462,13 @@ async def test_zeroconf_rejects_ipv6(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("fd00::b27c:63bb:cc85:4ea0"),
|
||||
ip_addresses=[ip_address("fd00::b27c:63bb:cc85:4ea0")],
|
||||
hostname="mock_hostname",
|
||||
name="shelly1pm-12345",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "shelly1pm-12345"},
|
||||
properties={ATTR_PROPERTIES_ID: "shelly1pm-12345"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
|
|
@ -7,7 +7,6 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.smappee.const import (
|
||||
CONF_SERIALNUMBER,
|
||||
DOMAIN,
|
||||
|
@ -20,6 +19,7 @@ from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
@ -63,7 +63,7 @@ async def test_show_zeroconf_connection_error_form(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
@ -95,7 +95,7 @@ async def test_show_zeroconf_connection_error_form_next_generation(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
@ -179,7 +179,7 @@ async def test_zeroconf_wrong_mdns(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
@ -305,7 +305,7 @@ async def test_zeroconf_device_exists_abort(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
@ -355,7 +355,7 @@ async def test_zeroconf_abort_if_cloud_device_exists(hass: HomeAssistant) -> Non
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
@ -377,7 +377,7 @@ async def test_zeroconf_confirm_abort_if_cloud_device_exists(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
@ -504,7 +504,7 @@ async def test_full_zeroconf_flow(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
@ -589,7 +589,7 @@ async def test_full_zeroconf_flow_next_generation(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
port=22,
|
||||
|
|
|
@ -6,18 +6,18 @@ from unittest.mock import AsyncMock, MagicMock
|
|||
from pysmlight.exceptions import SmlightAuthError, SmlightConnectionError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.smlight.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from .conftest import MOCK_HOST, MOCK_PASSWORD, MOCK_USERNAME
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
DISCOVERY_INFO = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
hostname="slzb-06.local.",
|
||||
|
@ -27,7 +27,7 @@ DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
|||
type="mock_type",
|
||||
)
|
||||
|
||||
DISCOVERY_INFO_LEGACY = zeroconf.ZeroconfServiceInfo(
|
||||
DISCOVERY_INFO_LEGACY = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
hostname="slzb-06.local.",
|
||||
|
|
|
@ -5,7 +5,6 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.somfy_mylink.const import (
|
||||
CONF_REVERSED_TARGET_IDS,
|
||||
CONF_SYSTEM_ID,
|
||||
|
@ -14,6 +13,7 @@ from homeassistant.components.somfy_mylink.const import (
|
|||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -263,7 +263,7 @@ async def test_form_user_already_configured_from_dhcp(hass: HomeAssistant) -> No
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="aabbccddeeff",
|
||||
hostname="somfy_eeff",
|
||||
|
@ -287,7 +287,7 @@ async def test_already_configured_with_ignored(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="aabbccddeeff",
|
||||
hostname="somfy_eeff",
|
||||
|
@ -302,7 +302,7 @@ async def test_dhcp_discovery(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="aabbccddeeff",
|
||||
hostname="somfy_eeff",
|
||||
|
|
|
@ -4,7 +4,6 @@ import copy
|
|||
import dataclasses
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.songpal.const import CONF_ENDPOINT, DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_IMPORT,
|
||||
|
@ -15,6 +14,11 @@ from homeassistant.config_entries import (
|
|||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_FRIENDLY_NAME,
|
||||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
from . import (
|
||||
CONF_DATA,
|
||||
|
@ -30,13 +34,13 @@ from tests.common import MockConfigEntry
|
|||
|
||||
UDN = "uuid:1234"
|
||||
|
||||
SSDP_DATA = ssdp.SsdpServiceInfo(
|
||||
SSDP_DATA = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=f"http://{HOST}:52323/dmr.xml",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_UDN: UDN,
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: FRIENDLY_NAME,
|
||||
ATTR_UPNP_UDN: UDN,
|
||||
ATTR_UPNP_FRIENDLY_NAME: FRIENDLY_NAME,
|
||||
"X_ScalarWebAPI_DeviceInfo": {
|
||||
"X_ScalarWebAPI_BaseURL": ENDPOINT,
|
||||
"X_ScalarWebAPI_ServiceList": {
|
||||
|
|
|
@ -18,11 +18,13 @@ from soco.data_structures import (
|
|||
)
|
||||
from soco.events_base import Event as SonosEvent
|
||||
|
||||
from homeassistant.components import ssdp, zeroconf
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
||||
from homeassistant.components.sonos import DOMAIN
|
||||
from homeassistant.const import CONF_HOSTS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.service_info.ssdp import ATTR_UPNP_UDN, SsdpServiceInfo
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture, load_json_value_fixture
|
||||
|
@ -108,7 +110,7 @@ class SonosMockEvent:
|
|||
@pytest.fixture
|
||||
def zeroconf_payload():
|
||||
"""Return a default zeroconf payload."""
|
||||
return zeroconf.ZeroconfServiceInfo(
|
||||
return ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.4.2"),
|
||||
ip_addresses=[ip_address("192.168.4.2")],
|
||||
hostname="Sonos-aaa",
|
||||
|
@ -335,17 +337,17 @@ def discover_fixture(soco):
|
|||
def do_callback(
|
||||
hass: HomeAssistant,
|
||||
callback: Callable[
|
||||
[ssdp.SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
[SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
],
|
||||
match_dict: dict[str, str] | None = None,
|
||||
) -> MagicMock:
|
||||
callback(
|
||||
ssdp.SsdpServiceInfo(
|
||||
SsdpServiceInfo(
|
||||
ssdp_location=f"http://{soco.ip_address}/",
|
||||
ssdp_st="urn:schemas-upnp-org:device:ZonePlayer:1",
|
||||
ssdp_usn=f"uuid:{soco.uid}_MR::urn:schemas-upnp-org:service:GroupRenderingControl:1",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_UDN: f"uuid:{soco.uid}",
|
||||
ATTR_UPNP_UDN: f"uuid:{soco.uid}",
|
||||
},
|
||||
),
|
||||
ssdp.SsdpChange.ALIVE,
|
||||
|
|
|
@ -6,17 +6,18 @@ from ipaddress import ip_address
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp, zeroconf
|
||||
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
||||
from homeassistant.components.sonos.const import DATA_SONOS_DISCOVERY_MANAGER, DOMAIN
|
||||
from homeassistant.const import CONF_HOSTS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import ATTR_UPNP_UDN, SsdpServiceInfo
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_user_form(
|
||||
hass: HomeAssistant, zeroconf_payload: zeroconf.ZeroconfServiceInfo
|
||||
hass: HomeAssistant, zeroconf_payload: ZeroconfServiceInfo
|
||||
) -> None:
|
||||
"""Test we get the user initiated form."""
|
||||
|
||||
|
@ -84,7 +85,7 @@ async def test_user_form_already_created(hass: HomeAssistant) -> None:
|
|||
|
||||
|
||||
async def test_zeroconf_form(
|
||||
hass: HomeAssistant, zeroconf_payload: zeroconf.ZeroconfServiceInfo
|
||||
hass: HomeAssistant, zeroconf_payload: ZeroconfServiceInfo
|
||||
) -> None:
|
||||
"""Test we pass Zeroconf discoveries to the manager."""
|
||||
|
||||
|
@ -128,12 +129,12 @@ async def test_ssdp_discovery(hass: HomeAssistant, soco) -> None:
|
|||
await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_location=f"http://{soco.ip_address}/",
|
||||
ssdp_st="urn:schemas-upnp-org:device:ZonePlayer:1",
|
||||
ssdp_usn=f"uuid:{soco.uid}_MR::urn:schemas-upnp-org:service:GroupRenderingControl:1",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_UDN: f"uuid:{soco.uid}",
|
||||
ATTR_UPNP_UDN: f"uuid:{soco.uid}",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -173,7 +174,7 @@ async def test_zeroconf_sonos_v1(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.107"),
|
||||
ip_addresses=[ip_address("192.168.1.107")],
|
||||
port=1443,
|
||||
|
@ -221,7 +222,7 @@ async def test_zeroconf_sonos_v1(hass: HomeAssistant) -> None:
|
|||
|
||||
|
||||
async def test_zeroconf_form_not_sonos(
|
||||
hass: HomeAssistant, zeroconf_payload: zeroconf.ZeroconfServiceInfo
|
||||
hass: HomeAssistant, zeroconf_payload: ZeroconfServiceInfo
|
||||
) -> None:
|
||||
"""Test we abort on non-sonos devices."""
|
||||
mock_manager = hass.data[DATA_SONOS_DISCOVERY_MANAGER] = MagicMock()
|
||||
|
|
|
@ -8,7 +8,7 @@ from unittest.mock import Mock, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import sonos, zeroconf
|
||||
from homeassistant.components import sonos
|
||||
from homeassistant.components.sonos import SonosDiscoveryManager
|
||||
from homeassistant.components.sonos.const import (
|
||||
DATA_SONOS_DISCOVERY_MANAGER,
|
||||
|
@ -19,6 +19,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
@ -28,7 +29,7 @@ from tests.common import async_fire_time_changed
|
|||
|
||||
|
||||
async def test_creating_entry_sets_up_media_player(
|
||||
hass: HomeAssistant, zeroconf_payload: zeroconf.ZeroconfServiceInfo
|
||||
hass: HomeAssistant, zeroconf_payload: ZeroconfServiceInfo
|
||||
) -> None:
|
||||
"""Test setting up Sonos loads the media player."""
|
||||
|
||||
|
|
|
@ -7,18 +7,18 @@ from unittest.mock import MagicMock, patch
|
|||
import pytest
|
||||
from spotifyaio import SpotifyConnectionError
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.spotify.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
BLANK_ZEROCONF_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
BLANK_ZEROCONF_INFO = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.2.3.4"),
|
||||
ip_addresses=[ip_address("1.2.3.4")],
|
||||
hostname="mock_hostname",
|
||||
|
|
|
@ -6,11 +6,11 @@ from unittest.mock import patch
|
|||
from pysqueezebox import Server
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.squeezebox.const import CONF_HTTPS, DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -333,7 +333,7 @@ async def test_dhcp_discovery(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="aabbccddeeff",
|
||||
hostname="any",
|
||||
|
@ -355,7 +355,7 @@ async def test_dhcp_discovery_no_server_found(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="aabbccddeeff",
|
||||
hostname="any",
|
||||
|
@ -374,7 +374,7 @@ async def test_dhcp_discovery_existing_player(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="aabbccddeeff",
|
||||
hostname="any",
|
||||
|
|
|
@ -94,7 +94,7 @@ async def test_ssdp_flow_dispatched_on_st(
|
|||
"discovery_key": DiscoveryKey(domain="ssdp", key="uuid:mock-udn", version=1),
|
||||
"source": config_entries.SOURCE_SSDP,
|
||||
}
|
||||
mock_call_data: ssdp.SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
mock_call_data: SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
assert mock_call_data.ssdp_st == "mock-st"
|
||||
assert mock_call_data.ssdp_location == "http://1.1.1.1"
|
||||
assert mock_call_data.ssdp_usn == "uuid:mock-udn::mock-st"
|
||||
|
@ -103,7 +103,7 @@ async def test_ssdp_flow_dispatched_on_st(
|
|||
assert mock_call_data.ssdp_udn == ANY
|
||||
assert mock_call_data.ssdp_headers["_timestamp"] == ANY
|
||||
assert mock_call_data.x_homeassistant_matching_domains == {"mock-domain"}
|
||||
assert mock_call_data.upnp == {ssdp.ATTR_UPNP_UDN: "uuid:mock-udn"}
|
||||
assert mock_call_data.upnp == {ATTR_UPNP_UDN: "uuid:mock-udn"}
|
||||
assert "Failed to fetch ssdp data" not in caplog.text
|
||||
|
||||
|
||||
|
@ -138,7 +138,7 @@ async def test_ssdp_flow_dispatched_on_manufacturer_url(
|
|||
"discovery_key": DiscoveryKey(domain="ssdp", key="uuid:mock-udn", version=1),
|
||||
"source": config_entries.SOURCE_SSDP,
|
||||
}
|
||||
mock_call_data: ssdp.SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
mock_call_data: SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
assert mock_call_data.ssdp_st == "mock-st"
|
||||
assert mock_call_data.ssdp_location == "http://1.1.1.1"
|
||||
assert mock_call_data.ssdp_usn == "uuid:mock-udn::mock-st"
|
||||
|
@ -147,7 +147,7 @@ async def test_ssdp_flow_dispatched_on_manufacturer_url(
|
|||
assert mock_call_data.ssdp_udn == ANY
|
||||
assert mock_call_data.ssdp_headers["_timestamp"] == ANY
|
||||
assert mock_call_data.x_homeassistant_matching_domains == {"mock-domain"}
|
||||
assert mock_call_data.upnp == {ssdp.ATTR_UPNP_UDN: "uuid:mock-udn"}
|
||||
assert mock_call_data.upnp == {ATTR_UPNP_UDN: "uuid:mock-udn"}
|
||||
assert "Failed to fetch ssdp data" not in caplog.text
|
||||
|
||||
|
||||
|
@ -247,8 +247,8 @@ async def test_scan_match_upnp_devicedesc_devicetype(
|
|||
return_value={
|
||||
"mock-domain": [
|
||||
{
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ssdp.ATTR_UPNP_MANUFACTURER: "Paulus",
|
||||
ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ATTR_UPNP_MANUFACTURER: "Paulus",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -290,8 +290,8 @@ async def test_scan_not_all_present(
|
|||
return_value={
|
||||
"mock-domain": [
|
||||
{
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ssdp.ATTR_UPNP_MANUFACTURER: "Not-Paulus",
|
||||
ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ATTR_UPNP_MANUFACTURER: "Not-Paulus",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -475,8 +475,8 @@ async def test_discovery_from_advertisement_sets_ssdp_st(
|
|||
assert discovery_info.ssdp_headers["nts"] == "ssdp:alive"
|
||||
assert discovery_info.ssdp_headers["_timestamp"] == ANY
|
||||
assert discovery_info.upnp == {
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ssdp.ATTR_UPNP_UDN: "uuid:mock-udn",
|
||||
ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ATTR_UPNP_UDN: "uuid:mock-udn",
|
||||
}
|
||||
|
||||
|
||||
|
@ -575,7 +575,7 @@ async def test_scan_with_registered_callback(
|
|||
assert async_match_any_callback.call_count == 1
|
||||
assert async_not_matching_integration_callback.call_count == 0
|
||||
assert async_integration_callback.call_args[0][1] == ssdp.SsdpChange.ALIVE
|
||||
mock_call_data: ssdp.SsdpServiceInfo = async_integration_callback.call_args[0][0]
|
||||
mock_call_data: SsdpServiceInfo = async_integration_callback.call_args[0][0]
|
||||
assert mock_call_data.ssdp_ext == ""
|
||||
assert mock_call_data.ssdp_location == "http://1.1.1.1"
|
||||
assert mock_call_data.ssdp_server == "mock-server"
|
||||
|
@ -588,8 +588,8 @@ async def test_scan_with_registered_callback(
|
|||
assert mock_call_data.ssdp_headers["_timestamp"] == ANY
|
||||
assert mock_call_data.x_homeassistant_matching_domains == set()
|
||||
assert mock_call_data.upnp == {
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
}
|
||||
assert "Exception in SSDP callback" in caplog.text
|
||||
|
||||
|
@ -647,8 +647,8 @@ async def test_getting_existing_headers(
|
|||
assert discovery_info_by_st.ssdp_udn == ANY
|
||||
assert discovery_info_by_st.ssdp_headers["_timestamp"] == ANY
|
||||
assert discovery_info_by_st.upnp == {
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
}
|
||||
|
||||
discovery_info_by_udn = await ssdp.async_get_discovery_info_by_udn(
|
||||
|
@ -666,8 +666,8 @@ async def test_getting_existing_headers(
|
|||
assert discovery_info_by_udn.ssdp_udn == ANY
|
||||
assert discovery_info_by_udn.ssdp_headers["_timestamp"] == ANY
|
||||
assert discovery_info_by_udn.upnp == {
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
}
|
||||
|
||||
discovery_info_by_udn_st = await ssdp.async_get_discovery_info_by_udn_st(
|
||||
|
@ -684,8 +684,8 @@ async def test_getting_existing_headers(
|
|||
assert discovery_info_by_udn_st.ssdp_udn == ANY
|
||||
assert discovery_info_by_udn_st.ssdp_headers["_timestamp"] == ANY
|
||||
assert discovery_info_by_udn_st.upnp == {
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
ATTR_UPNP_DEVICE_TYPE: "Paulus",
|
||||
ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
}
|
||||
|
||||
assert (
|
||||
|
@ -733,7 +733,7 @@ _ADAPTERS_WITH_MANUAL_CONFIG = [
|
|||
return_value={
|
||||
"mock-domain": [
|
||||
{
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "ABC",
|
||||
ATTR_UPNP_DEVICE_TYPE: "ABC",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -758,7 +758,7 @@ async def test_async_detect_interfaces_setting_empty_route(
|
|||
return_value={
|
||||
"mock-domain": [
|
||||
{
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "ABC",
|
||||
ATTR_UPNP_DEVICE_TYPE: "ABC",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -807,7 +807,7 @@ async def test_bind_failure_skips_adapter(
|
|||
return_value={
|
||||
"mock-domain": [
|
||||
{
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "ABC",
|
||||
ATTR_UPNP_DEVICE_TYPE: "ABC",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1019,7 +1019,7 @@ async def test_ssdp_rediscover(
|
|||
assert len(mock_flow_init.mock_calls) == 1
|
||||
assert mock_flow_init.mock_calls[0][1][0] == "mock-domain"
|
||||
assert mock_flow_init.mock_calls[0][2]["context"] == expected_context
|
||||
mock_call_data: ssdp.SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
mock_call_data: SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
assert mock_call_data.ssdp_st == "mock-st"
|
||||
assert mock_call_data.ssdp_location == "http://1.1.1.1"
|
||||
|
||||
|
@ -1106,7 +1106,7 @@ async def test_ssdp_rediscover_no_match(
|
|||
assert len(mock_flow_init.mock_calls) == 1
|
||||
assert mock_flow_init.mock_calls[0][1][0] == "mock-domain"
|
||||
assert mock_flow_init.mock_calls[0][2]["context"] == expected_context
|
||||
mock_call_data: ssdp.SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
mock_call_data: SsdpServiceInfo = mock_flow_init.mock_calls[0][2]["data"]
|
||||
assert mock_call_data.ssdp_st == "mock-st"
|
||||
assert mock_call_data.ssdp_location == "http://1.1.1.1"
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.steamist.const import DOMAIN
|
||||
from homeassistant.const import CONF_DEVICE, CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from . import (
|
||||
DEFAULT_ENTRY_DATA,
|
||||
|
@ -30,7 +30,7 @@ from tests.common import MockConfigEntry
|
|||
MODULE = "homeassistant.components.steamist"
|
||||
|
||||
|
||||
DHCP_DISCOVERY = dhcp.DhcpServiceInfo(
|
||||
DHCP_DISCOVERY = DhcpServiceInfo(
|
||||
hostname=DEVICE_HOSTNAME,
|
||||
ip=DEVICE_IP_ADDRESS,
|
||||
macaddress=DEVICE_MAC_ADDRESS.lower().replace(":", ""),
|
||||
|
@ -238,7 +238,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result3 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="any",
|
||||
ip=DEVICE_IP_ADDRESS,
|
||||
macaddress="000000000000",
|
||||
|
|
|
@ -6,12 +6,19 @@ from unittest.mock import patch
|
|||
from pysyncthru import SyncThruAPINotSupported
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.syncthru.config_flow import SyncThru
|
||||
from homeassistant.components.syncthru.const import DOMAIN
|
||||
from homeassistant.const import CONF_NAME, CONF_URL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_DEVICE_TYPE,
|
||||
ATTR_UPNP_MANUFACTURER,
|
||||
ATTR_UPNP_PRESENTATION_URL,
|
||||
ATTR_UPNP_SERIAL,
|
||||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
@ -138,16 +145,16 @@ async def test_ssdp(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) ->
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://192.168.1.2:5200/Printer.xml",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:Printer:1",
|
||||
ssdp.ATTR_UPNP_MANUFACTURER: "Samsung Electronics",
|
||||
ssdp.ATTR_UPNP_PRESENTATION_URL: url,
|
||||
ssdp.ATTR_UPNP_SERIAL: "00000000",
|
||||
ssdp.ATTR_UPNP_UDN: "uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
|
||||
ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:Printer:1",
|
||||
ATTR_UPNP_MANUFACTURER: "Samsung Electronics",
|
||||
ATTR_UPNP_PRESENTATION_URL: url,
|
||||
ATTR_UPNP_SERIAL: "00000000",
|
||||
ATTR_UPNP_UDN: "uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
|
|
@ -13,7 +13,6 @@ from synology_dsm.exceptions import (
|
|||
)
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components import ssdp, zeroconf
|
||||
from homeassistant.components.synology_dsm.config_flow import CONF_OTP_CODE
|
||||
from homeassistant.components.synology_dsm.const import (
|
||||
CONF_SNAPSHOT_QUALITY,
|
||||
|
@ -34,6 +33,12 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_FRIENDLY_NAME,
|
||||
ATTR_UPNP_SERIAL,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from .consts import (
|
||||
DEVICE_TOKEN,
|
||||
|
@ -418,13 +423,13 @@ async def test_form_ssdp(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://192.168.1.5:5000",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ssdp.ATTR_UPNP_SERIAL: "001132XXXX99", # MAC address, but SSDP does not have `-`
|
||||
ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ATTR_UPNP_SERIAL: "001132XXXX99", # MAC address, but SSDP does not have `-`
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -465,13 +470,13 @@ async def test_reconfig_ssdp(hass: HomeAssistant, service: MagicMock) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://192.168.1.5:5000",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ssdp.ATTR_UPNP_SERIAL: "001132XXXX59", # Existing in MACS[0], but SSDP does not have `-`
|
||||
ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ATTR_UPNP_SERIAL: "001132XXXX59", # Existing in MACS[0], but SSDP does not have `-`
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -508,13 +513,13 @@ async def test_skip_reconfig_ssdp(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=f"http://{new_host}:5000",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ssdp.ATTR_UPNP_SERIAL: "001132XXXX59", # Existing in MACS[0], but SSDP does not have `-`
|
||||
ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ATTR_UPNP_SERIAL: "001132XXXX59", # Existing in MACS[0], but SSDP does not have `-`
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -541,13 +546,13 @@ async def test_existing_ssdp(hass: HomeAssistant, service: MagicMock) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://192.168.1.5:5000",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ssdp.ATTR_UPNP_SERIAL: "001132XXXX59", # Existing in MACS[0], but SSDP does not have `-`
|
||||
ATTR_UPNP_FRIENDLY_NAME: "mydsm",
|
||||
ATTR_UPNP_SERIAL: "001132XXXX59", # Existing in MACS[0], but SSDP does not have `-`
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -606,7 +611,7 @@ async def test_discovered_via_zeroconf(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.5"),
|
||||
ip_addresses=[ip_address("192.168.1.5")],
|
||||
port=5000,
|
||||
|
@ -645,7 +650,7 @@ async def test_discovered_via_zeroconf_missing_mac(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.5"),
|
||||
ip_addresses=[ip_address("192.168.1.5")],
|
||||
port=5000,
|
||||
|
|
|
@ -15,9 +15,9 @@ from systembridgemodels.fixtures.modules.processes import FIXTURE_PROCESSES
|
|||
from systembridgemodels.fixtures.modules.system import FIXTURE_SYSTEM
|
||||
from systembridgemodels.modules import Module, ModulesData
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -44,7 +44,7 @@ FIXTURE_ZEROCONF_INPUT = {
|
|||
CONF_PORT: "9170",
|
||||
}
|
||||
|
||||
FIXTURE_ZEROCONF = zeroconf.ZeroconfServiceInfo(
|
||||
FIXTURE_ZEROCONF = ZeroconfServiceInfo(
|
||||
ip_address=ip_address(FIXTURE_USER_INPUT[CONF_HOST]),
|
||||
ip_addresses=[ip_address(FIXTURE_USER_INPUT[CONF_HOST])],
|
||||
port=9170,
|
||||
|
@ -62,7 +62,7 @@ FIXTURE_ZEROCONF = zeroconf.ZeroconfServiceInfo(
|
|||
},
|
||||
)
|
||||
|
||||
FIXTURE_ZEROCONF_BAD = zeroconf.ZeroconfServiceInfo(
|
||||
FIXTURE_ZEROCONF_BAD = ZeroconfServiceInfo(
|
||||
ip_address=ip_address(FIXTURE_USER_INPUT[CONF_HOST]),
|
||||
ip_addresses=[ip_address(FIXTURE_USER_INPUT[CONF_HOST])],
|
||||
port=9170,
|
||||
|
|
|
@ -9,7 +9,6 @@ import pytest
|
|||
import requests
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.tado.config_flow import NoHomes
|
||||
from homeassistant.components.tado.const import (
|
||||
CONF_FALLBACK,
|
||||
|
@ -19,6 +18,10 @@ from homeassistant.components.tado.const import (
|
|||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import (
|
||||
ATTR_PROPERTIES_ID,
|
||||
ZeroconfServiceInfo,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -235,13 +238,13 @@ async def test_form_homekit(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
properties={ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
@ -262,13 +265,13 @@ async def test_form_homekit(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
properties={ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
|
|
@ -11,13 +11,13 @@ from gotailwind import (
|
|||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.tailwind.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -156,7 +156,7 @@ async def test_zeroconf_flow(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
port=80,
|
||||
|
@ -208,7 +208,7 @@ async def test_zeroconf_flow_abort_incompatible_properties(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
port=80,
|
||||
|
@ -243,7 +243,7 @@ async def test_zeroconf_flow_errors(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
port=80,
|
||||
|
@ -303,7 +303,7 @@ async def test_zeroconf_flow_not_discovered_again(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
port=80,
|
||||
|
|
|
@ -6,12 +6,12 @@ from unittest.mock import AsyncMock, MagicMock
|
|||
import pytest
|
||||
from technove import TechnoVEConnectionError
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.technove.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -112,7 +112,7 @@ async def test_full_zeroconf_flow_implementation(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -153,7 +153,7 @@ async def test_zeroconf_during_onboarding(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -184,7 +184,7 @@ async def test_zeroconf_connection_error(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -225,7 +225,7 @@ async def test_zeroconf_without_mac_station_exists_abort(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -250,7 +250,7 @@ async def test_zeroconf_with_mac_station_exists_abort(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
|
|
@ -5,11 +5,11 @@ from unittest.mock import patch
|
|||
from tesla_wall_connector.exceptions import WallConnectorConnectionError
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.tesla_wall_connector.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -113,7 +113,7 @@ async def test_dhcp_can_finish(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="teslawallconnector_abc",
|
||||
ip="1.2.3.4",
|
||||
macaddress="aadc44271212",
|
||||
|
@ -146,7 +146,7 @@ async def test_dhcp_already_exists(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="teslawallconnector_aabbcc",
|
||||
ip="1.2.3.4",
|
||||
macaddress="aabbccddeeff",
|
||||
|
@ -170,7 +170,7 @@ async def test_dhcp_error_from_wall_connector(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="teslawallconnector_aabbcc",
|
||||
ip="1.2.3.4",
|
||||
macaddress="aabbccddeeff",
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
from ipaddress import ip_address
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components import thread, zeroconf
|
||||
from homeassistant.components import thread
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
TEST_ZEROCONF_RECORD = zeroconf.ZeroconfServiceInfo(
|
||||
TEST_ZEROCONF_RECORD = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("127.0.0.1"),
|
||||
ip_addresses=[ip_address("127.0.0.1")],
|
||||
hostname="HomeAssistant OpenThreadBorderRouter #0BBF",
|
||||
|
|
|
@ -5,14 +5,14 @@ from unittest.mock import Mock, patch
|
|||
import pytest
|
||||
from tololib import ToloCommunicationError
|
||||
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.tolo.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
MOCK_DHCP_DATA = dhcp.DhcpServiceInfo(
|
||||
MOCK_DHCP_DATA = DhcpServiceInfo(
|
||||
ip="127.0.0.2", macaddress="001122334455", hostname="mock_hostname"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from kasa import Module, TimeoutError
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp, stream
|
||||
from homeassistant.components import stream
|
||||
from homeassistant.components.tplink import (
|
||||
DOMAIN,
|
||||
AuthenticationError,
|
||||
|
@ -36,6 +36,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from . import _mocked_device, _patch_connect, _patch_discovery, _patch_single_discovery
|
||||
from .conftest import override_side_effect
|
||||
|
@ -1291,7 +1292,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result2 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress=DHCP_FORMATTED_MAC_ADDRESS, hostname=ALIAS
|
||||
),
|
||||
)
|
||||
|
@ -1305,7 +1306,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result3 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress="000000000000", hostname="mock_hostname"
|
||||
),
|
||||
)
|
||||
|
@ -1321,7 +1322,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result3 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.2.3.5", macaddress="000000000001", hostname="mock_hostname"
|
||||
),
|
||||
)
|
||||
|
@ -1335,7 +1336,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
|||
[
|
||||
(
|
||||
config_entries.SOURCE_DHCP,
|
||||
dhcp.DhcpServiceInfo(
|
||||
DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress=DHCP_FORMATTED_MAC_ADDRESS, hostname=ALIAS
|
||||
),
|
||||
),
|
||||
|
@ -1389,7 +1390,7 @@ async def test_discovered_by_dhcp_or_discovery(
|
|||
[
|
||||
(
|
||||
config_entries.SOURCE_DHCP,
|
||||
dhcp.DhcpServiceInfo(
|
||||
DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress=DHCP_FORMATTED_MAC_ADDRESS, hostname=ALIAS
|
||||
),
|
||||
),
|
||||
|
@ -1606,7 +1607,7 @@ async def test_dhcp_discovery_with_ip_change(
|
|||
discovery_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=IP_ADDRESS2, macaddress=DHCP_FORMATTED_MAC_ADDRESS, hostname=ALIAS
|
||||
),
|
||||
)
|
||||
|
@ -1631,7 +1632,7 @@ async def test_dhcp_discovery_discover_fail(
|
|||
discovery_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=IP_ADDRESS2, macaddress=DHCP_FORMATTED_MAC_ADDRESS, hostname=ALIAS
|
||||
),
|
||||
)
|
||||
|
|
|
@ -6,10 +6,13 @@ from unittest.mock import AsyncMock, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.tradfri import config_flow
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import (
|
||||
ATTR_PROPERTIES_ID,
|
||||
ZeroconfServiceInfo,
|
||||
)
|
||||
|
||||
from . import TRADFRI_PATH
|
||||
|
||||
|
@ -115,13 +118,13 @@ async def test_discovery_connection(
|
|||
flow = await hass.config_entries.flow.async_init(
|
||||
"tradfri",
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("123.123.123.123"),
|
||||
ip_addresses=[ip_address("123.123.123.123")],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
properties={ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
@ -150,13 +153,13 @@ async def test_discovery_duplicate_aborted(hass: HomeAssistant) -> None:
|
|||
flow = await hass.config_entries.flow.async_init(
|
||||
"tradfri",
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("123.123.123.124"),
|
||||
ip_addresses=[ip_address("123.123.123.124")],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
properties={ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
@ -174,13 +177,13 @@ async def test_duplicate_discovery(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
"tradfri",
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("123.123.123.123"),
|
||||
ip_addresses=[ip_address("123.123.123.123")],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
properties={ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
@ -190,13 +193,13 @@ async def test_duplicate_discovery(
|
|||
result2 = await hass.config_entries.flow.async_init(
|
||||
"tradfri",
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("123.123.123.123"),
|
||||
ip_addresses=[ip_address("123.123.123.123")],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
properties={ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
@ -215,13 +218,13 @@ async def test_discovery_updates_unique_id(hass: HomeAssistant) -> None:
|
|||
flow = await hass.config_entries.flow.async_init(
|
||||
"tradfri",
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("123.123.123.123"),
|
||||
ip_addresses=[ip_address("123.123.123.123")],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
properties={ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
|
|
@ -4,12 +4,12 @@ from unittest.mock import AsyncMock
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.twinkly.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER
|
||||
from homeassistant.const import CONF_HOST, CONF_ID, CONF_MODEL, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from .const import TEST_MAC, TEST_MODEL, TEST_NAME
|
||||
|
||||
|
@ -95,7 +95,7 @@ async def test_dhcp_full_flow(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="Twinkly_XYZ",
|
||||
ip="1.2.3.4",
|
||||
macaddress="002d133baabb",
|
||||
|
@ -127,7 +127,7 @@ async def test_dhcp_already_configured(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="Twinkly_XYZ",
|
||||
ip="1.2.3.4",
|
||||
macaddress="002d133baabb",
|
||||
|
@ -146,7 +146,7 @@ async def test_user_flow_works_discovery(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
hostname="Twinkly_XYZ",
|
||||
ip="1.2.3.4",
|
||||
macaddress="002d133baabb",
|
||||
|
|
|
@ -7,7 +7,6 @@ import aiounifi
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.unifi.config_flow import _async_discover_unifi
|
||||
from homeassistant.components.unifi.const import (
|
||||
CONF_ALLOW_BANDWIDTH_SENSORS,
|
||||
|
@ -33,6 +32,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo
|
||||
|
||||
from .conftest import ConfigEntryFactoryType
|
||||
|
||||
|
@ -482,7 +482,7 @@ async def test_form_ssdp(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
UNIFI_DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://192.168.208.1:41417/rootDesc.xml",
|
||||
|
@ -522,7 +522,7 @@ async def test_form_ssdp_aborts_if_host_already_exists(hass: HomeAssistant) -> N
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
UNIFI_DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://1.2.3.4:1234/rootDesc.xml",
|
||||
|
@ -544,7 +544,7 @@ async def test_form_ssdp_aborts_if_serial_already_exists(hass: HomeAssistant) ->
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
UNIFI_DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://1.2.3.4:1234/rootDesc.xml",
|
||||
|
@ -570,7 +570,7 @@ async def test_form_ssdp_gets_form_with_ignored_entry(hass: HomeAssistant) -> No
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
UNIFI_DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://1.2.3.4:1234/rootDesc.xml",
|
||||
|
|
|
@ -11,7 +11,6 @@ from uiprotect import NotAuthorized, NvrError, ProtectApiClient
|
|||
from uiprotect.data import NVR, Bootstrap, CloudAccount
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp, ssdp
|
||||
from homeassistant.components.unifiprotect.const import (
|
||||
CONF_ALL_UPDATES,
|
||||
CONF_DISABLE_RTSP,
|
||||
|
@ -23,6 +22,8 @@ from homeassistant.const import CONF_HOST
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo
|
||||
|
||||
from . import (
|
||||
DEVICE_HOSTNAME,
|
||||
|
@ -37,13 +38,13 @@ from .conftest import MAC_ADDR
|
|||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
DHCP_DISCOVERY = dhcp.DhcpServiceInfo(
|
||||
DHCP_DISCOVERY = DhcpServiceInfo(
|
||||
hostname=DEVICE_HOSTNAME,
|
||||
ip=DEVICE_IP_ADDRESS,
|
||||
macaddress=DEVICE_MAC_ADDRESS.lower().replace(":", ""),
|
||||
)
|
||||
SSDP_DISCOVERY = (
|
||||
ssdp.SsdpServiceInfo(
|
||||
SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=f"http://{DEVICE_IP_ADDRESS}:41417/rootDesc.xml",
|
||||
|
@ -338,7 +339,7 @@ async def test_form_options(hass: HomeAssistant, ufp_client: ProtectApiClient) -
|
|||
],
|
||||
)
|
||||
async def test_discovered_by_ssdp_or_dhcp(
|
||||
hass: HomeAssistant, source: str, data: dhcp.DhcpServiceInfo | ssdp.SsdpServiceInfo
|
||||
hass: HomeAssistant, source: str, data: DhcpServiceInfo | SsdpServiceInfo
|
||||
) -> None:
|
||||
"""Test we handoff to unifi-discovery when discovered via ssdp or dhcp."""
|
||||
|
||||
|
|
|
@ -25,6 +25,15 @@ from homeassistant.components.upnp.const import (
|
|||
DOMAIN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_DEVICE_TYPE,
|
||||
ATTR_UPNP_FRIENDLY_NAME,
|
||||
ATTR_UPNP_MANUFACTURER,
|
||||
ATTR_UPNP_MODEL_NAME,
|
||||
ATTR_UPNP_SERIAL,
|
||||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -36,7 +45,7 @@ TEST_LOCATION6 = "http://[fe80::1%2]/desc.xml"
|
|||
TEST_HOST = urlparse(TEST_LOCATION).hostname
|
||||
TEST_FRIENDLY_NAME = "mock-name"
|
||||
TEST_MAC_ADDRESS = "00:11:22:33:44:55"
|
||||
TEST_DISCOVERY = ssdp.SsdpServiceInfo(
|
||||
TEST_DISCOVERY = SsdpServiceInfo(
|
||||
ssdp_st=TEST_ST,
|
||||
ssdp_udn=TEST_UDN,
|
||||
ssdp_usn=TEST_USN,
|
||||
|
@ -45,12 +54,12 @@ TEST_DISCOVERY = ssdp.SsdpServiceInfo(
|
|||
"_udn": TEST_UDN,
|
||||
"location": TEST_LOCATION,
|
||||
"usn": TEST_USN,
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: TEST_ST,
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: TEST_FRIENDLY_NAME,
|
||||
ssdp.ATTR_UPNP_MANUFACTURER: "mock-manufacturer",
|
||||
ssdp.ATTR_UPNP_MODEL_NAME: "mock-model-name",
|
||||
ssdp.ATTR_UPNP_SERIAL: "mock-serial",
|
||||
ssdp.ATTR_UPNP_UDN: TEST_UDN,
|
||||
ATTR_UPNP_DEVICE_TYPE: TEST_ST,
|
||||
ATTR_UPNP_FRIENDLY_NAME: TEST_FRIENDLY_NAME,
|
||||
ATTR_UPNP_MANUFACTURER: "mock-manufacturer",
|
||||
ATTR_UPNP_MODEL_NAME: "mock-model-name",
|
||||
ATTR_UPNP_SERIAL: "mock-serial",
|
||||
ATTR_UPNP_UDN: TEST_UDN,
|
||||
},
|
||||
ssdp_headers={
|
||||
"_host": TEST_HOST,
|
||||
|
@ -75,13 +84,13 @@ def mock_igd_device(mock_async_create_device) -> IgdDevice:
|
|||
"""Mock async_upnp_client device."""
|
||||
mock_upnp_device = create_autospec(UpnpDevice, instance=True)
|
||||
mock_upnp_device.device_url = TEST_DISCOVERY.ssdp_location
|
||||
mock_upnp_device.serial_number = TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_SERIAL]
|
||||
mock_upnp_device.serial_number = TEST_DISCOVERY.upnp[ATTR_UPNP_SERIAL]
|
||||
|
||||
mock_igd_device = create_autospec(IgdDevice)
|
||||
mock_igd_device.device_type = TEST_DISCOVERY.ssdp_st
|
||||
mock_igd_device.name = TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]
|
||||
mock_igd_device.manufacturer = TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_MANUFACTURER]
|
||||
mock_igd_device.model_name = TEST_DISCOVERY.upnp[ssdp.ATTR_UPNP_MODEL_NAME]
|
||||
mock_igd_device.name = TEST_DISCOVERY.upnp[ATTR_UPNP_FRIENDLY_NAME]
|
||||
mock_igd_device.manufacturer = TEST_DISCOVERY.upnp[ATTR_UPNP_MANUFACTURER]
|
||||
mock_igd_device.model_name = TEST_DISCOVERY.upnp[ATTR_UPNP_MODEL_NAME]
|
||||
mock_igd_device.udn = TEST_DISCOVERY.ssdp_udn
|
||||
mock_igd_device.device = mock_upnp_device
|
||||
|
||||
|
@ -179,7 +188,7 @@ async def ssdp_instant_discovery():
|
|||
async def register_callback(
|
||||
hass: HomeAssistant,
|
||||
callback: Callable[
|
||||
[ssdp.SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
[SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
],
|
||||
match_dict: dict[str, str] | None = None,
|
||||
) -> MagicMock:
|
||||
|
@ -212,7 +221,7 @@ async def ssdp_instant_discovery_multi_location():
|
|||
async def register_callback(
|
||||
hass: HomeAssistant,
|
||||
callback: Callable[
|
||||
[ssdp.SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
[SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
],
|
||||
match_dict: dict[str, str] | None = None,
|
||||
) -> MagicMock:
|
||||
|
@ -241,7 +250,7 @@ async def ssdp_no_discovery():
|
|||
async def register_callback(
|
||||
hass: HomeAssistant,
|
||||
callback: Callable[
|
||||
[ssdp.SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
[SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
],
|
||||
match_dict: dict[str, str] | None = None,
|
||||
) -> MagicMock:
|
||||
|
|
|
@ -7,7 +7,6 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.upnp.const import (
|
||||
CONFIG_ENTRY_FORCE_POLL,
|
||||
CONFIG_ENTRY_HOST,
|
||||
|
@ -21,6 +20,11 @@ from homeassistant.components.upnp.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_DEVICE_TYPE,
|
||||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
from .conftest import (
|
||||
TEST_DISCOVERY,
|
||||
|
@ -109,14 +113,14 @@ async def test_flow_ssdp_incomplete_discovery(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn=TEST_USN,
|
||||
# ssdp_udn=TEST_UDN, # Not provided.
|
||||
ssdp_st=TEST_ST,
|
||||
ssdp_location=TEST_LOCATION,
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: ST_IGD_V1,
|
||||
# ssdp.ATTR_UPNP_UDN: TEST_UDN, # Not provided.
|
||||
ATTR_UPNP_DEVICE_TYPE: ST_IGD_V1,
|
||||
# ATTR_UPNP_UDN: TEST_UDN, # Not provided.
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -130,14 +134,14 @@ async def test_flow_ssdp_non_igd_device(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn=TEST_USN,
|
||||
ssdp_udn=TEST_UDN,
|
||||
ssdp_st=TEST_ST,
|
||||
ssdp_location=TEST_LOCATION,
|
||||
ssdp_all_locations=[TEST_LOCATION],
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:WFADevice:1", # Non-IGD
|
||||
ATTR_UPNP_DEVICE_TYPE: "urn:schemas-upnp-org:device:WFADevice:1", # Non-IGD
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -449,7 +453,7 @@ async def test_flow_ssdp_with_mismatched_udn(hass: HomeAssistant) -> None:
|
|||
"""Test config flow: discovered + configured through ssdp, where the UDN differs in the SSDP-discovery vs device description."""
|
||||
# Discovered via step ssdp.
|
||||
test_discovery = copy.deepcopy(TEST_DISCOVERY)
|
||||
test_discovery.upnp[ssdp.ATTR_UPNP_UDN] = "uuid:another_udn"
|
||||
test_discovery.upnp[ATTR_UPNP_UDN] = "uuid:another_udn"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
|
|
@ -22,6 +22,7 @@ from homeassistant.components.upnp.const import (
|
|||
DOMAIN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.service_info.ssdp import ATTR_UPNP_UDN, SsdpServiceInfo
|
||||
|
||||
from .conftest import (
|
||||
TEST_DISCOVERY,
|
||||
|
@ -125,7 +126,7 @@ async def test_async_setup_udn_mismatch(
|
|||
) -> None:
|
||||
"""Test async_setup_entry for a device which reports a different UDN from SSDP-discovery and device description."""
|
||||
test_discovery = copy.deepcopy(TEST_DISCOVERY)
|
||||
test_discovery.upnp[ssdp.ATTR_UPNP_UDN] = "uuid:another_udn"
|
||||
test_discovery.upnp[ATTR_UPNP_UDN] = "uuid:another_udn"
|
||||
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -146,7 +147,7 @@ async def test_async_setup_udn_mismatch(
|
|||
async def register_callback(
|
||||
hass: HomeAssistant,
|
||||
callback: Callable[
|
||||
[ssdp.SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
[SsdpServiceInfo, ssdp.SsdpChange], Coroutine[Any, Any, None] | None
|
||||
],
|
||||
match_dict: dict[str, str] | None = None,
|
||||
) -> MagicMock:
|
||||
|
|
|
@ -8,7 +8,6 @@ import pytest
|
|||
from verisure import Error as VerisureError, LoginError as VerisureLoginError
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.verisure.const import (
|
||||
CONF_GIID,
|
||||
CONF_LOCK_CODE_DIGITS,
|
||||
|
@ -18,6 +17,7 @@ from homeassistant.components.verisure.const import (
|
|||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -333,7 +333,7 @@ async def test_dhcp(hass: HomeAssistant) -> None:
|
|||
"""Test that DHCP discovery works."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.2.3.4", macaddress="0123456789ab", hostname="mock_hostname"
|
||||
),
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
|
|
|
@ -9,12 +9,12 @@ from PyViCare.PyViCareUtils import (
|
|||
)
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.vicare.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from . import MOCK_MAC, MODULE
|
||||
|
||||
|
@ -28,7 +28,7 @@ VALID_CONFIG = {
|
|||
CONF_CLIENT_ID: "5678",
|
||||
}
|
||||
|
||||
DHCP_INFO = dhcp.DhcpServiceInfo(
|
||||
DHCP_INFO = DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
hostname="mock_hostname",
|
||||
macaddress=MOCK_MAC.lower().replace(":", ""),
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from ipaddress import ip_address
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.media_player import (
|
||||
DOMAIN as MP_DOMAIN,
|
||||
MediaPlayerDeviceClass,
|
||||
|
@ -27,6 +26,7 @@ from homeassistant.const import (
|
|||
CONF_NAME,
|
||||
CONF_PIN,
|
||||
)
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
from homeassistant.util import slugify
|
||||
|
||||
NAME = "Vizio"
|
||||
|
@ -173,7 +173,7 @@ VIZIO_ZEROCONF_SERVICE_TYPE = "_viziocast._tcp.local."
|
|||
ZEROCONF_NAME = f"{NAME}.{VIZIO_ZEROCONF_SERVICE_TYPE}"
|
||||
ZEROCONF_HOST, ZEROCONF_PORT = HOST.split(":", maxsplit=2)
|
||||
|
||||
MOCK_ZEROCONF_SERVICE_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
MOCK_ZEROCONF_SERVICE_INFO = ZeroconfServiceInfo(
|
||||
ip_address=ip_address(ZEROCONF_HOST),
|
||||
ip_addresses=[ip_address(ZEROCONF_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
|
|
@ -4,11 +4,11 @@ from ipaddress import ip_address
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.volumio.config_flow import CannotConnectError
|
||||
from homeassistant.components.volumio.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -21,7 +21,7 @@ TEST_CONNECTION = {
|
|||
}
|
||||
|
||||
|
||||
TEST_DISCOVERY = zeroconf.ZeroconfServiceInfo(
|
||||
TEST_DISCOVERY = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("1.1.1.1"),
|
||||
ip_addresses=[ip_address("1.1.1.1")],
|
||||
hostname="mock_hostname",
|
||||
|
|
|
@ -4,12 +4,16 @@ from aiowebostv import WebOsTvPairError
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.webostv.const import CONF_SOURCES, DOMAIN, LIVE_TV_APP_ID
|
||||
from homeassistant.config_entries import SOURCE_SSDP
|
||||
from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST, CONF_SOURCE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_FRIENDLY_NAME,
|
||||
ATTR_UPNP_UDN,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
from . import setup_webostv
|
||||
from .const import (
|
||||
|
@ -26,13 +30,13 @@ pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
|||
|
||||
MOCK_USER_CONFIG = {CONF_HOST: HOST}
|
||||
|
||||
MOCK_DISCOVERY_INFO = ssdp.SsdpServiceInfo(
|
||||
MOCK_DISCOVERY_INFO = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=f"http://{HOST}",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: f"[LG] webOS TV {TV_MODEL}",
|
||||
ssdp.ATTR_UPNP_UDN: f"uuid:{FAKE_UUID}",
|
||||
ATTR_UPNP_FRIENDLY_NAME: f"[LG] webOS TV {TV_MODEL}",
|
||||
ATTR_UPNP_UDN: f"uuid:{FAKE_UUID}",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -239,8 +243,8 @@ async def test_ssdp_in_progress(hass: HomeAssistant, client) -> None:
|
|||
|
||||
async def test_form_abort_uuid_configured(hass: HomeAssistant, client) -> None:
|
||||
"""Test abort if uuid is already configured, verify host update."""
|
||||
entry = await setup_webostv(hass, MOCK_DISCOVERY_INFO.upnp[ssdp.ATTR_UPNP_UDN][5:])
|
||||
assert entry.unique_id == MOCK_DISCOVERY_INFO.upnp[ssdp.ATTR_UPNP_UDN][5:]
|
||||
entry = await setup_webostv(hass, MOCK_DISCOVERY_INFO.upnp[ATTR_UPNP_UDN][5:])
|
||||
assert entry.unique_id == MOCK_DISCOVERY_INFO.upnp[ATTR_UPNP_UDN][5:]
|
||||
assert entry.data[CONF_HOST] == HOST
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from pywilight.const import DOMAIN
|
||||
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.wilight.config_flow import (
|
||||
CONF_MODEL_NAME,
|
||||
CONF_SERIAL_NUMBER,
|
||||
|
@ -14,6 +13,7 @@ from homeassistant.helpers.service_info.ssdp import (
|
|||
ATTR_UPNP_MODEL_NAME,
|
||||
ATTR_UPNP_MODEL_NUMBER,
|
||||
ATTR_UPNP_SERIAL,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -34,7 +34,7 @@ UPNP_MAC_ADDRESS = "5C:CF:7F:8B:CA:56"
|
|||
UPNP_MANUFACTURER_NOT_WILIGHT = "Test"
|
||||
CONF_COMPONENTS = "components"
|
||||
|
||||
MOCK_SSDP_DISCOVERY_INFO_P_B = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DISCOVERY_INFO_P_B = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=SSDP_LOCATION,
|
||||
|
@ -46,7 +46,7 @@ MOCK_SSDP_DISCOVERY_INFO_P_B = ssdp.SsdpServiceInfo(
|
|||
},
|
||||
)
|
||||
|
||||
MOCK_SSDP_DISCOVERY_INFO_WRONG_MANUFACTURER = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DISCOVERY_INFO_WRONG_MANUFACTURER = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=SSDP_LOCATION,
|
||||
|
@ -58,7 +58,7 @@ MOCK_SSDP_DISCOVERY_INFO_WRONG_MANUFACTURER = ssdp.SsdpServiceInfo(
|
|||
},
|
||||
)
|
||||
|
||||
MOCK_SSDP_DISCOVERY_INFO_MISSING_MANUFACTURER = ssdp.SsdpServiceInfo(
|
||||
MOCK_SSDP_DISCOVERY_INFO_MISSING_MANUFACTURER = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location=SSDP_LOCATION,
|
||||
|
|
|
@ -6,13 +6,13 @@ import pytest
|
|||
from pywizlight.exceptions import WizLightConnectionError, WizLightTimeOutError
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.wiz.config_flow import CONF_DEVICE
|
||||
from homeassistant.components.wiz.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
|
||||
from . import (
|
||||
FAKE_DIMMABLE_BULB,
|
||||
|
@ -32,7 +32,7 @@ from . import (
|
|||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
DHCP_DISCOVERY = dhcp.DhcpServiceInfo(
|
||||
DHCP_DISCOVERY = DhcpServiceInfo(
|
||||
hostname="wiz_abcabc",
|
||||
ip=FAKE_IP,
|
||||
macaddress=FAKE_MAC,
|
||||
|
|
|
@ -6,12 +6,12 @@ from unittest.mock import AsyncMock, MagicMock
|
|||
import pytest
|
||||
from wled import WLEDConnectionError
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.wled.const import CONF_KEEP_MAIN_LIGHT, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -43,7 +43,7 @@ async def test_full_zeroconf_flow_implementation(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -87,7 +87,7 @@ async def test_zeroconf_during_onboarding(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -132,7 +132,7 @@ async def test_zeroconf_connection_error(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -175,7 +175,7 @@ async def test_zeroconf_without_mac_device_exists_abort(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
@ -200,7 +200,7 @@ async def test_zeroconf_with_mac_device_exists_abort(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.123"),
|
||||
ip_addresses=[ip_address("192.168.1.123")],
|
||||
hostname="example.local.",
|
||||
|
|
|
@ -7,11 +7,11 @@ from unittest.mock import Mock, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.xiaomi_aqara import config_flow, const
|
||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_PROTOCOL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
ZEROCONF_NAME = "name"
|
||||
ZEROCONF_PROP = "properties"
|
||||
|
@ -409,7 +409,7 @@ async def test_zeroconf_success(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(TEST_HOST),
|
||||
ip_addresses=[ip_address(TEST_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
@ -456,7 +456,7 @@ async def test_zeroconf_missing_data(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(TEST_HOST),
|
||||
ip_addresses=[ip_address(TEST_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
@ -476,7 +476,7 @@ async def test_zeroconf_unknown_device(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(TEST_HOST),
|
||||
ip_addresses=[ip_address(TEST_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
|
|
@ -9,11 +9,11 @@ from miio import DeviceException
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.xiaomi_miio import const
|
||||
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MAC, CONF_MODEL, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from . import TEST_MAC
|
||||
|
||||
|
@ -434,7 +434,7 @@ async def test_zeroconf_gateway_success(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(TEST_HOST),
|
||||
ip_addresses=[ip_address(TEST_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
@ -477,7 +477,7 @@ async def test_zeroconf_unknown_device(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(TEST_HOST),
|
||||
ip_addresses=[ip_address(TEST_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
@ -497,7 +497,7 @@ async def test_zeroconf_no_data(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=None,
|
||||
ip_addresses=[],
|
||||
hostname="mock_hostname",
|
||||
|
@ -517,7 +517,7 @@ async def test_zeroconf_missing_data(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(TEST_HOST),
|
||||
ip_addresses=[ip_address(TEST_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
@ -801,7 +801,7 @@ async def zeroconf_device_success(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(TEST_HOST),
|
||||
ip_addresses=[ip_address(TEST_HOST)],
|
||||
hostname="mock_hostname",
|
||||
|
|
|
@ -7,12 +7,16 @@ from aiomusiccast import MusicCastConnectionException
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.yamaha_musiccast.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_MODEL_NAME,
|
||||
ATTR_UPNP_SERIAL,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -103,7 +107,7 @@ def mock_valid_discovery_information():
|
|||
with patch(
|
||||
"homeassistant.components.ssdp.async_get_discovery_info_by_st",
|
||||
return_value=[
|
||||
ssdp.SsdpServiceInfo(
|
||||
SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://127.0.0.1:9000/MediaRenderer/desc.xml",
|
||||
|
@ -265,13 +269,13 @@ async def test_ssdp_discovery_failed(hass: HomeAssistant, mock_ssdp_no_yamaha) -
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://127.0.0.1/desc.xml",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_MODEL_NAME: "MC20",
|
||||
ssdp.ATTR_UPNP_SERIAL: "123456789",
|
||||
ATTR_UPNP_MODEL_NAME: "MC20",
|
||||
ATTR_UPNP_SERIAL: "123456789",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -287,13 +291,13 @@ async def test_ssdp_discovery_successful_add_device(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://127.0.0.1/desc.xml",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_MODEL_NAME: "MC20",
|
||||
ssdp.ATTR_UPNP_SERIAL: "1234567890",
|
||||
ATTR_UPNP_MODEL_NAME: "MC20",
|
||||
ATTR_UPNP_SERIAL: "1234567890",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -329,13 +333,13 @@ async def test_ssdp_discovery_existing_device_update(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://127.0.0.1/desc.xml",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_MODEL_NAME: "MC20",
|
||||
ssdp.ATTR_UPNP_SERIAL: "1234567890",
|
||||
ATTR_UPNP_MODEL_NAME: "MC20",
|
||||
ATTR_UPNP_SERIAL: "1234567890",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
|
|
@ -9,7 +9,6 @@ from async_upnp_client.utils import CaseInsensitiveDict
|
|||
from yeelight import BulbException, BulbType
|
||||
from yeelight.main import _MODEL_SPECS
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.yeelight import (
|
||||
CONF_MODE_MUSIC,
|
||||
CONF_NIGHTLIGHT_SWITCH_TYPE,
|
||||
|
@ -21,6 +20,7 @@ from homeassistant.components.yeelight import (
|
|||
)
|
||||
from homeassistant.const import CONF_DEVICES, CONF_ID, CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
FAIL_TO_BIND_IP = "1.2.3.4"
|
||||
|
||||
|
@ -43,7 +43,7 @@ CAPABILITIES = {
|
|||
|
||||
ID_DECIMAL = f"{int(ID, 16):08d}"
|
||||
|
||||
ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo(
|
||||
ZEROCONF_DATA = ZeroconfServiceInfo(
|
||||
ip_address=ip_address(IP_ADDRESS),
|
||||
ip_addresses=[ip_address(IP_ADDRESS)],
|
||||
port=54321,
|
||||
|
|
|
@ -6,7 +6,6 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp, ssdp, zeroconf
|
||||
from homeassistant.components.yeelight.config_flow import (
|
||||
MODEL_UNKNOWN,
|
||||
CannotConnect,
|
||||
|
@ -30,6 +29,12 @@ from homeassistant.components.yeelight.const import (
|
|||
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_ID, CONF_MODEL, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo
|
||||
from homeassistant.helpers.service_info.zeroconf import (
|
||||
ATTR_PROPERTIES_ID,
|
||||
ZeroconfServiceInfo,
|
||||
)
|
||||
|
||||
from . import (
|
||||
CAPABILITIES,
|
||||
|
@ -57,7 +62,7 @@ DEFAULT_CONFIG = {
|
|||
CONF_NIGHTLIGHT_SWITCH: DEFAULT_NIGHTLIGHT_SWITCH,
|
||||
}
|
||||
|
||||
SSDP_INFO = ssdp.SsdpServiceInfo(
|
||||
SSDP_INFO = SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
upnp={},
|
||||
|
@ -493,13 +498,13 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
data=ZeroconfServiceInfo(
|
||||
ip_address=ip_address(IP_ADDRESS),
|
||||
ip_addresses=[ip_address(IP_ADDRESS)],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
properties={ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
@ -525,7 +530,7 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result2 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress="aabbccddeeff", hostname="mock_hostname"
|
||||
),
|
||||
)
|
||||
|
@ -543,7 +548,7 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result3 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress="000000000000", hostname="mock_hostname"
|
||||
),
|
||||
)
|
||||
|
@ -560,7 +565,7 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
|||
result3 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
data=DhcpServiceInfo(
|
||||
ip="1.2.3.5", macaddress="000000000001", hostname="mock_hostname"
|
||||
),
|
||||
)
|
||||
|
@ -574,19 +579,19 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
|||
[
|
||||
(
|
||||
config_entries.SOURCE_DHCP,
|
||||
dhcp.DhcpServiceInfo(
|
||||
DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress="aabbccddeeff", hostname="mock_hostname"
|
||||
),
|
||||
),
|
||||
(
|
||||
config_entries.SOURCE_HOMEKIT,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
ZeroconfServiceInfo(
|
||||
ip_address=ip_address(IP_ADDRESS),
|
||||
ip_addresses=[ip_address(IP_ADDRESS)],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
properties={ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
),
|
||||
|
@ -648,19 +653,19 @@ async def test_discovered_by_dhcp_or_homekit(hass: HomeAssistant, source, data)
|
|||
[
|
||||
(
|
||||
config_entries.SOURCE_DHCP,
|
||||
dhcp.DhcpServiceInfo(
|
||||
DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress="aabbccddeeff", hostname="mock_hostname"
|
||||
),
|
||||
),
|
||||
(
|
||||
config_entries.SOURCE_HOMEKIT,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
ZeroconfServiceInfo(
|
||||
ip_address=ip_address(IP_ADDRESS),
|
||||
ip_addresses=[ip_address(IP_ADDRESS)],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
properties={ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
),
|
||||
|
@ -894,19 +899,19 @@ async def test_discovery_adds_missing_ip_id_only(hass: HomeAssistant) -> None:
|
|||
[
|
||||
(
|
||||
config_entries.SOURCE_DHCP,
|
||||
dhcp.DhcpServiceInfo(
|
||||
DhcpServiceInfo(
|
||||
ip=IP_ADDRESS, macaddress="aabbccddeeff", hostname="mock_hostname"
|
||||
),
|
||||
),
|
||||
(
|
||||
config_entries.SOURCE_HOMEKIT,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
ZeroconfServiceInfo(
|
||||
ip_address=ip_address(IP_ADDRESS),
|
||||
ip_addresses=[ip_address(IP_ADDRESS)],
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
properties={ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
),
|
||||
|
|
|
@ -20,7 +20,6 @@ from zigpy.exceptions import NetworkNotFormed
|
|||
import zigpy.types
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp, zeroconf
|
||||
from homeassistant.components.hassio import AddonError, AddonState
|
||||
from homeassistant.components.zha import config_flow, radio_manager
|
||||
from homeassistant.components.zha.const import (
|
||||
|
@ -45,8 +44,10 @@ from homeassistant.data_entry_flow import FlowResultType
|
|||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_UPNP_MANUFACTURER_URL,
|
||||
ATTR_UPNP_SERIAL,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
from homeassistant.helpers.service_info.usb import UsbServiceInfo
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -166,7 +167,7 @@ def com_port(device="/dev/ttyUSB1234") -> ListPortInfo:
|
|||
"tubeszb-cc2652-poe",
|
||||
"tubeszb-cc2652-poe",
|
||||
RadioType.znp,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="tubeszb-cc2652-poe.local.",
|
||||
|
@ -189,7 +190,7 @@ def com_port(device="/dev/ttyUSB1234") -> ListPortInfo:
|
|||
"tubeszb-efr32-poe",
|
||||
"tubeszb-efr32-poe",
|
||||
RadioType.ezsp,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="tubeszb-efr32-poe.local.",
|
||||
|
@ -212,7 +213,7 @@ def com_port(device="/dev/ttyUSB1234") -> ListPortInfo:
|
|||
"TubeZB",
|
||||
"tubeszb-cc2652-poe",
|
||||
RadioType.znp,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="tubeszb-cc2652-poe.local.",
|
||||
|
@ -233,7 +234,7 @@ def com_port(device="/dev/ttyUSB1234") -> ListPortInfo:
|
|||
"Some Zigbee Gateway (12345)",
|
||||
"aabbccddeeff",
|
||||
RadioType.znp,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="some-zigbee-gateway-12345.local.",
|
||||
|
@ -252,7 +253,7 @@ async def test_zeroconf_discovery(
|
|||
entry_name: str,
|
||||
unique_id: str,
|
||||
radio_type: RadioType,
|
||||
service_info: zeroconf.ZeroconfServiceInfo,
|
||||
service_info: ZeroconfServiceInfo,
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test zeroconf flow -- radio detected."""
|
||||
|
@ -294,7 +295,7 @@ async def test_legacy_zeroconf_discovery_zigate(
|
|||
setup_entry_mock, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test zeroconf flow -- zigate radio detected."""
|
||||
service_info = zeroconf.ZeroconfServiceInfo(
|
||||
service_info = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="_zigate-zigbee-gateway.local.",
|
||||
|
@ -343,7 +344,7 @@ async def test_legacy_zeroconf_discovery_zigate(
|
|||
|
||||
async def test_zeroconf_discovery_bad_payload(hass: HomeAssistant) -> None:
|
||||
"""Test zeroconf flow with a bad payload."""
|
||||
service_info = zeroconf.ZeroconfServiceInfo(
|
||||
service_info = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="some.hostname",
|
||||
|
@ -371,7 +372,7 @@ async def test_legacy_zeroconf_discovery_ip_change_ignored(hass: HomeAssistant)
|
|||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
service_info = zeroconf.ZeroconfServiceInfo(
|
||||
service_info = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="tubeszb-cc2652-poe.local.",
|
||||
|
@ -401,7 +402,7 @@ async def test_legacy_zeroconf_discovery_confirm_final_abort_if_entries(
|
|||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test discovery aborts if ZHA was set up after the confirmation dialog is shown."""
|
||||
service_info = zeroconf.ZeroconfServiceInfo(
|
||||
service_info = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="tube._tube_zb_gw._tcp.local.",
|
||||
|
@ -626,7 +627,7 @@ async def test_discovery_via_usb_deconz_already_discovered(hass: HomeAssistant)
|
|||
"""Test usb flow -- deconz discovered."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"deconz",
|
||||
data=ssdp.SsdpServiceInfo(
|
||||
data=SsdpServiceInfo(
|
||||
ssdp_usn="mock_usn",
|
||||
ssdp_st="mock_st",
|
||||
ssdp_location="http://1.2.3.4:80/",
|
||||
|
@ -736,7 +737,7 @@ async def test_discovery_via_usb_zha_ignored_updates(hass: HomeAssistant) -> Non
|
|||
@patch(f"zigpy_znp.{PROBE_FUNCTION_PATH}", AsyncMock(return_value=True))
|
||||
async def test_legacy_zeroconf_discovery_already_setup(hass: HomeAssistant) -> None:
|
||||
"""Test zeroconf flow -- radio detected."""
|
||||
service_info = zeroconf.ZeroconfServiceInfo(
|
||||
service_info = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.200"),
|
||||
ip_addresses=[ip_address("192.168.1.200")],
|
||||
hostname="_tube_zb_gw._tcp.local.",
|
||||
|
|
|
@ -4,14 +4,14 @@ from ipaddress import ip_address
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.zwave_me.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult, FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
MOCK_ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo(
|
||||
MOCK_ZEROCONF_DATA = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("192.168.1.14"),
|
||||
ip_addresses=[ip_address("192.168.1.14")],
|
||||
hostname="mock_hostname",
|
||||
|
|
Loading…
Reference in New Issue