Update ZeroconfServiceInfo in tests (t-z) (#60221)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
cbbf22db52
commit
9f74ad06d6
6 changed files with 101 additions and 9 deletions
|
@ -106,7 +106,11 @@ async def test_discovery_connection(hass, mock_auth, mock_entry_setup):
|
|||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="123.123.123.123",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -256,7 +260,12 @@ async def test_discovery_duplicate_aborted(hass):
|
|||
"tradfri",
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="new-host", properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"}
|
||||
host="new-host",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -287,7 +296,11 @@ async def test_duplicate_discovery(hass, mock_auth, mock_entry_setup):
|
|||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="123.123.123.123",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -298,7 +311,11 @@ async def test_duplicate_discovery(hass, mock_auth, mock_entry_setup):
|
|||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="123.123.123.123",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -317,7 +334,12 @@ async def test_discovery_updates_unique_id(hass):
|
|||
"tradfri",
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="some-host", properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"}
|
||||
host="some-host",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "homekit-id"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -19,8 +19,11 @@ TEST_CONNECTION = {
|
|||
|
||||
TEST_DISCOVERY = zeroconf.ZeroconfServiceInfo(
|
||||
host="1.1.1.1",
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=3000,
|
||||
properties={"volumioName": "discovered", "UUID": "2222-2222-2222-2222"},
|
||||
type="mock_type",
|
||||
)
|
||||
|
||||
TEST_DISCOVERY_RESULT = {
|
||||
|
|
|
@ -49,7 +49,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",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -104,7 +109,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",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -126,7 +136,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",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -160,7 +175,12 @@ async def test_zeroconf_device_exists_abort(
|
|||
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",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -180,7 +200,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: "aabbccddeeff"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -403,8 +403,11 @@ async def test_zeroconf_success(hass):
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name=TEST_ZEROCONF_NAME,
|
||||
port=None,
|
||||
properties={ZEROCONF_MAC: TEST_MAC},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -445,7 +448,12 @@ async def test_zeroconf_missing_data(hass):
|
|||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST, name=TEST_ZEROCONF_NAME, properties={}
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name=TEST_ZEROCONF_NAME,
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -460,8 +468,11 @@ async def test_zeroconf_unknown_device(hass):
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name="not-a-xiaomi-aqara-gateway",
|
||||
port=None,
|
||||
properties={ZEROCONF_MAC: TEST_MAC},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -394,8 +394,11 @@ async def test_zeroconf_gateway_success(hass):
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name=TEST_ZEROCONF_NAME,
|
||||
port=None,
|
||||
properties={ZEROCONF_MAC: TEST_MAC},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -433,8 +436,11 @@ async def test_zeroconf_unknown_device(hass):
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name="not-a-xiaomi-miio-device",
|
||||
port=None,
|
||||
properties={ZEROCONF_MAC: TEST_MAC},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -447,7 +453,14 @@ async def test_zeroconf_no_data(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(host=None, name=None, properties={}),
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=None,
|
||||
hostname="mock_hostname",
|
||||
name=None,
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
|
@ -460,7 +473,12 @@ async def test_zeroconf_missing_data(hass):
|
|||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST, name=TEST_ZEROCONF_NAME, properties={}
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name=TEST_ZEROCONF_NAME,
|
||||
port=None,
|
||||
properties={},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -753,8 +771,11 @@ async def zeroconf_device_success(hass, zeroconf_name_to_test, model_to_test):
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
hostname="mock_hostname",
|
||||
name=zeroconf_name_to_test,
|
||||
port=None,
|
||||
properties={"poch": f"0:mac={TEST_MAC_DEVICE}\x00"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -458,7 +458,11 @@ async def test_discovered_by_homekit_and_dhcp(hass):
|
|||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=IP_ADDRESS,
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -523,7 +527,11 @@ async def test_discovered_by_homekit_and_dhcp(hass):
|
|||
config_entries.SOURCE_HOMEKIT,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
host=IP_ADDRESS,
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -586,7 +594,11 @@ async def test_discovered_by_dhcp_or_homekit(hass, source, data):
|
|||
config_entries.SOURCE_HOMEKIT,
|
||||
zeroconf.ZeroconfServiceInfo(
|
||||
host=IP_ADDRESS,
|
||||
hostname="mock_hostname",
|
||||
name="mock_name",
|
||||
port=None,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
type="mock_type",
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Add table
Reference in a new issue