Update ZeroconfServiceInfo in tests (g-m) (#60217)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-11-23 16:42:38 +01:00 committed by GitHub
parent 7e08238cd8
commit 31b033ac25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 87 additions and 13 deletions

View file

@ -108,7 +108,12 @@ async def test_form_homekit_unique_id_already_setup(hass):
DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
data=zeroconf.ZeroconfServiceInfo(
host="1.2.3.4", properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR}
host="1.2.3.4",
hostname="mock_hostname",
name="mock_name",
port=None,
properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR},
type="mock_type",
),
)
assert result["type"] == RESULT_TYPE_FORM
@ -130,7 +135,12 @@ async def test_form_homekit_unique_id_already_setup(hass):
DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
data=zeroconf.ZeroconfServiceInfo(
host="1.2.3.4", properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR}
host="1.2.3.4",
hostname="mock_hostname",
name="mock_name",
port=None,
properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR},
type="mock_type",
),
)
assert result["type"] == RESULT_TYPE_ABORT
@ -149,7 +159,12 @@ async def test_form_homekit_ip_address_already_setup(hass):
DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
data=zeroconf.ZeroconfServiceInfo(
host="1.2.3.4", properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR}
host="1.2.3.4",
hostname="mock_hostname",
name="mock_name",
port=None,
properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR},
type="mock_type",
),
)
assert result["type"] == RESULT_TYPE_ABORT
@ -162,7 +177,12 @@ async def test_form_homekit_ip_address(hass):
DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
data=zeroconf.ZeroconfServiceInfo(
host="1.2.3.4", properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR}
host="1.2.3.4",
hostname="mock_hostname",
name="mock_name",
port=None,
properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR},
type="mock_type",
),
)
assert result["type"] == RESULT_TYPE_FORM
@ -239,7 +259,12 @@ async def test_discovered_by_homekit_and_dhcp(hass):
DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
data=zeroconf.ZeroconfServiceInfo(
host="1.2.3.4", properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR}
host="1.2.3.4",
hostname="mock_hostname",
name="mock_name",
port=None,
properties={zeroconf.ATTR_PROPERTIES_ID: MOCK_MAC_ADDR},
type="mock_type",
),
)
assert result["type"] == RESULT_TYPE_FORM

View file

@ -141,10 +141,9 @@ def get_device_discovery_info(
record = device.info
result = zeroconf.ZeroconfServiceInfo(
host=record["address"],
port=record["port"],
hostname=record["name"],
type="_hap._tcp.local.",
name=record["name"],
port=record["port"],
properties={
"md": record["md"],
"pv": record["pv"],
@ -156,6 +155,7 @@ def get_device_discovery_info(
"sf": 0x01, # record["sf"],
"sh": "",
},
type="_hap._tcp.local.",
)
if missing_csharp:

View file

@ -517,7 +517,11 @@ async def test_bridge_homekit(hass, aioclient_mock):
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",
),
)
@ -560,7 +564,11 @@ async def test_bridge_homekit_already_configured(hass, aioclient_mock):
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",
),
)

View file

@ -12,14 +12,21 @@ from homeassistant.components.hunterdouglas_powerview.const import DOMAIN
from tests.common import MockConfigEntry, load_fixture
HOMEKIT_DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
name="Hunter Douglas Powerview Hub._hap._tcp.local.",
host="1.2.3.4",
properties={"id": "AA::BB::CC::DD::EE::FF"},
hostname="mock_hostname",
name="Hunter Douglas Powerview Hub._hap._tcp.local.",
port=None,
properties={zeroconf.ATTR_PROPERTIES_ID: "AA::BB::CC::DD::EE::FF"},
type="mock_type",
)
ZEROCONF_DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
name="Hunter Douglas Powerview Hub._powerview._tcp.local.",
host="1.2.3.4",
hostname="mock_hostname",
name="Hunter Douglas Powerview Hub._powerview._tcp.local.",
port=None,
properties={},
type="mock_type",
)
DHCP_DISCOVERY_INFO = dhcp.DhcpServiceInfo(

View file

@ -428,6 +428,10 @@ async def test_zeroconf_host_already_configured(hass, tmpdir):
data=zeroconf.ZeroconfServiceInfo(
host="1.1.1.1",
hostname="lutron-abc.local.",
name="mock_name",
port=None,
properties={},
type="mock_type",
),
)
await hass.async_block_till_done()
@ -451,6 +455,10 @@ async def test_zeroconf_lutron_id_already_configured(hass):
data=zeroconf.ZeroconfServiceInfo(
host="1.1.1.1",
hostname="lutron-abc.local.",
name="mock_name",
port=None,
properties={},
type="mock_type",
),
)
await hass.async_block_till_done()
@ -469,6 +477,10 @@ async def test_zeroconf_not_lutron_device(hass):
data=zeroconf.ZeroconfServiceInfo(
host="1.1.1.1",
hostname="notlutron-abc.local.",
name="mock_name",
port=None,
properties={},
type="mock_type",
),
)
await hass.async_block_till_done()
@ -493,6 +505,10 @@ async def test_zeroconf(hass, source, tmpdir):
data=zeroconf.ZeroconfServiceInfo(
host="1.1.1.1",
hostname="lutron-abc.local.",
name="mock_name",
port=None,
properties={},
type="mock_type",
),
)
await hass.async_block_till_done()

View file

@ -70,7 +70,12 @@ async def test_full_zeroconf_flow_implementation(
DOMAIN,
context={"source": SOURCE_ZEROCONF},
data=zeroconf.ZeroconfServiceInfo(
host="192.168.1.123", hostname="example.local.", properties={}
host="192.168.1.123",
hostname="example.local.",
name="mock_name",
port=None,
properties={},
type="mock_type",
),
)
@ -134,7 +139,12 @@ async def test_zeroconf_connection_error(
DOMAIN,
context={"source": SOURCE_ZEROCONF},
data=zeroconf.ZeroconfServiceInfo(
host="192.168.1.123", hostname="example.local.", properties={}
host="192.168.1.123",
hostname="example.local.",
name="mock_name",
port=None,
properties={},
type="mock_type",
),
)
@ -160,7 +170,12 @@ async def test_zeroconf_confirm_connection_error(
CONF_NAME: "test",
},
data=zeroconf.ZeroconfServiceInfo(
host="192.168.1.123", hostname="example.com.", properties={}
host="192.168.1.123",
hostname="example.com.",
name="mock_name",
port=None,
properties={},
type="mock_type",
),
)
@ -226,7 +241,10 @@ async def test_zeroconf_with_mac_device_exists_abort(
data=zeroconf.ZeroconfServiceInfo(
host="192.168.1.123",
hostname="example.local.",
name="mock_name",
port=None,
properties={CONF_MAC: "AA:BB:CC:DD:EE:FF"},
type="mock_type",
),
)