Update ZeroconfServiceInfo in tests (n-t) (#60219)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
7a0ff4e2e1
commit
77dfeb062f
13 changed files with 119 additions and 22 deletions
|
@ -12,7 +12,14 @@ from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZERO
|
|||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(host="10.10.2.3")
|
||||
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
host="10.10.2.3",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
)
|
||||
VALID_CONFIG = {"host": "10.10.2.3"}
|
||||
VALID_AUTH = {"username": "fake_username", "password": "fake_password"}
|
||||
|
||||
|
|
|
@ -238,9 +238,11 @@ async def test_discovery_link_unavailable(
|
|||
context={"source": source},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name=f"{TEST_NAME}.{type_in_discovery_info}",
|
||||
type=type_in_discovery_info,
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: TEST_DEVICE_ID},
|
||||
type=type_in_discovery_info,
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
|
@ -420,9 +422,11 @@ async def test_import_discovery_integration(
|
|||
context={"source": source},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name=f"{TEST_NAME}.{type_in_discovery}",
|
||||
type=type_in_discovery,
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: TEST_DEVICE_ID},
|
||||
type=type_in_discovery,
|
||||
),
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
|
|
|
@ -42,7 +42,11 @@ async def test_abort_if_existing_entry(hass):
|
|||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="0.0.0.0",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
|
|
|
@ -35,7 +35,14 @@ async def test_form_zeroconf(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.5", port=1234),
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.5",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=1234,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
|
|
@ -172,9 +172,11 @@ async def test_show_zerconf_form(hass: HomeAssistant) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.123",
|
||||
port=80,
|
||||
hostname="example.local.",
|
||||
name="mock_name",
|
||||
port=80,
|
||||
properties={"uuid": "83747482", "path": "/foo/"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
|
@ -487,9 +489,11 @@ async def test_duplicate_zerconf_ignored(hass: HomeAssistant) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.123",
|
||||
port=80,
|
||||
hostname="example.local.",
|
||||
name="mock_name",
|
||||
port=80,
|
||||
properties={"uuid": "83747482", "path": "/foo/"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
|
|
|
@ -42,25 +42,27 @@ TEST_USERNAME2 = "stretch"
|
|||
|
||||
TEST_DISCOVERY = zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
port=DEFAULT_PORT,
|
||||
hostname=f"{TEST_HOSTNAME}.local.",
|
||||
server=f"{TEST_HOSTNAME}.local.",
|
||||
name="mock_name",
|
||||
port=DEFAULT_PORT,
|
||||
properties={
|
||||
"product": "smile",
|
||||
"version": "1.2.3",
|
||||
"hostname": f"{TEST_HOSTNAME}.local.",
|
||||
},
|
||||
type="mock_type",
|
||||
)
|
||||
TEST_DISCOVERY2 = zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
port=DEFAULT_PORT,
|
||||
hostname=f"{TEST_HOSTNAME2}.local.",
|
||||
server=f"{TEST_HOSTNAME2}.local.",
|
||||
name="mock_name",
|
||||
port=DEFAULT_PORT,
|
||||
properties={
|
||||
"product": "stretch",
|
||||
"version": "1.2.3",
|
||||
"hostname": f"{TEST_HOSTNAME2}.local.",
|
||||
},
|
||||
type="mock_type",
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -113,7 +113,12 @@ async def test_form_homekit(hass):
|
|||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}
|
||||
host="mock_host",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
|
@ -132,7 +137,12 @@ async def test_form_homekit(hass):
|
|||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}
|
||||
host="mock_host",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
|
|
|
@ -235,7 +235,14 @@ async def test_step_homekit_zeroconf_ip_already_exists(hass, source):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": source},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.100",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
|
@ -264,7 +271,14 @@ async def test_step_homekit_zeroconf_ip_change(hass, source):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": source},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.2"),
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.2",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
|
@ -295,7 +309,14 @@ async def test_step_homekit_zeroconf_new_controller_when_some_exist(hass, source
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": source},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.100",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
@ -339,7 +360,14 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.100",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
@ -352,7 +380,14 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(hass):
|
|||
result2 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.100",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
|
|
|
@ -33,11 +33,14 @@ MOCK_SSDP_DISCOVERY_INFO = {
|
|||
HOMEKIT_HOST = "192.168.1.161"
|
||||
|
||||
MOCK_HOMEKIT_DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
name="onn._hap._tcp.local.",
|
||||
host=HOMEKIT_HOST,
|
||||
hostname="mock_hostname",
|
||||
name="onn._hap._tcp.local.",
|
||||
port=None,
|
||||
properties={
|
||||
zeroconf.ATTR_PROPERTIES_ID: "2d:97:da:ee:dc:99",
|
||||
},
|
||||
type="mock_type",
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -90,6 +90,8 @@ MOCK_DHCP_DATA = dhcp.DhcpServiceInfo(
|
|||
EXISTING_IP = "192.168.40.221"
|
||||
MOCK_ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo(
|
||||
host="fake_host",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=1234,
|
||||
properties={
|
||||
"deviceid": "aa:bb:cc:dd:ee:ff",
|
||||
|
@ -97,6 +99,7 @@ MOCK_ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo(
|
|||
"model": "fake_model",
|
||||
"serialNumber": "fake_serial",
|
||||
},
|
||||
type="mock_type",
|
||||
)
|
||||
MOCK_OLD_ENTRY = {
|
||||
CONF_HOST: "fake_host",
|
||||
|
|
|
@ -19,8 +19,11 @@ MOCK_SETTINGS = {
|
|||
}
|
||||
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
host="1.1.1.1",
|
||||
hostname="mock_hostname",
|
||||
name="shelly1pm-12345",
|
||||
properties={"id": "shelly1pm-12345"},
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "shelly1pm-12345"},
|
||||
type="mock_type",
|
||||
)
|
||||
MOCK_CONFIG = {
|
||||
"wifi": {"ap": {"ssid": "Test name"}},
|
||||
|
|
|
@ -46,9 +46,11 @@ async def test_zeroconf_form(hass: core.HomeAssistant):
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.4.2",
|
||||
name="Sonos-aaa@Living Room._sonos._tcp.local.",
|
||||
hostname="Sonos-aaa",
|
||||
name="Sonos-aaa@Living Room._sonos._tcp.local.",
|
||||
port=None,
|
||||
properties={"bootseq": "1234"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
|
@ -136,7 +138,10 @@ async def test_zeroconf_form_not_sonos(hass: core.HomeAssistant):
|
|||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.4.2",
|
||||
hostname="not-aaa",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={"bootseq": "1234"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
|
|
|
@ -128,7 +128,12 @@ async def test_form_homekit(hass):
|
|||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}
|
||||
host="mock_host",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
|
@ -149,7 +154,12 @@ async def test_form_homekit(hass):
|
|||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}
|
||||
host="mock_host",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
|
|
Loading…
Add table
Reference in a new issue