示例#1
0
async def test_info_from_service_with_link_local_address_only(hass):
    """Test that the link local address is ignored."""
    service_type = "_test._tcp.local."
    service_info = get_service_info_mock(service_type, f"test.{service_type}")
    service_info.addresses = ["169.254.12.3"]
    info = zeroconf.info_from_service(service_info)
    assert info is None
示例#2
0
async def test_info_from_service_with_addresses(hass):
    """Test info_from_service does not throw when there are no addresses."""
    service_type = "_test._tcp.local."
    info = zeroconf.info_from_service(
        get_service_info_mock_without_an_address(service_type, f"test.{service_type}")
    )
    assert info is None
async def test_info_from_service_prefers_ipv4(hass):
    """Test that ipv4 addresses are preferred."""
    service_type = "_test._tcp.local."
    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"
示例#4
0
async def test_info_from_service_non_utf8(hass):
    """Test info_from_service handles non UTF-8 property values correctly."""
    service_type = "_test._tcp.local."
    info = zeroconf.info_from_service(
        get_service_info_mock(service_type, f"test.{service_type}"))
    raw_info = info["properties"].pop("_raw", False)
    assert raw_info
    assert len(info["properties"]) <= len(raw_info)
    assert "non-utf8-value" not in info["properties"]
    assert raw_info["non-utf8-value"] is not None
示例#5
0
async def test_info_from_service_non_utf8(hass):
    """Test info_from_service handles non UTF-8 property keys and values correctly."""
    service_type = "_test._tcp.local."
    info = zeroconf.info_from_service(
        get_service_info_mock(service_type, f"test.{service_type}"))
    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 raw_info["non-utf8-value"] is NON_UTF8_VALUE