Use dataclass properties in Zeroconf tests ()

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/61130/head
epenet 2021-12-06 20:16:39 +01:00 committed by GitHub
parent e712b80650
commit d64bf3cc6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions
tests/components/zeroconf

View File

@ -671,12 +671,12 @@ async def test_info_from_service_non_utf8(hass):
info = zeroconf.info_from_service(
get_service_info_mock(service_type, f"test.{service_type}")
)
raw_info = info["properties"].pop("_raw", False)
raw_info = info.properties.pop("_raw", False)
assert raw_info
assert len(raw_info) == len(PROPERTIES) - 1
assert NON_ASCII_KEY not in raw_info
assert len(info["properties"]) <= len(raw_info)
assert "non-utf8-value" not in info["properties"]
assert len(info.properties) <= len(raw_info)
assert "non-utf8-value" not in info.properties
assert raw_info["non-utf8-value"] is NON_UTF8_VALUE
@ -695,7 +695,7 @@ async def test_info_from_service_with_link_local_address_first(hass):
service_info = get_service_info_mock(service_type, f"test.{service_type}")
service_info.addresses = ["169.254.12.3", "192.168.66.12"]
info = zeroconf.info_from_service(service_info)
assert info["host"] == "192.168.66.12"
assert info.host == "192.168.66.12"
async def test_info_from_service_with_link_local_address_second(hass):
@ -704,7 +704,7 @@ async def test_info_from_service_with_link_local_address_second(hass):
service_info = get_service_info_mock(service_type, f"test.{service_type}")
service_info.addresses = ["192.168.66.12", "169.254.12.3"]
info = zeroconf.info_from_service(service_info)
assert info["host"] == "192.168.66.12"
assert info.host == "192.168.66.12"
async def test_info_from_service_with_link_local_address_only(hass):
@ -722,7 +722,7 @@ async def test_info_from_service_prefers_ipv4(hass):
service_info = get_service_info_mock(service_type, f"test.{service_type}")
service_info.addresses = ["2001:db8:3333:4444:5555:6666:7777:8888", "192.168.66.12"]
info = zeroconf.info_from_service(service_info)
assert info["host"] == "192.168.66.12"
assert info.host == "192.168.66.12"
async def test_get_instance(hass, mock_async_zeroconf):