|
17 | 17 |
|
18 | 18 | import zeroconf as r
|
19 | 19 | from zeroconf import DNSAddress, RecordUpdate, const
|
| 20 | +from zeroconf._protocol.outgoing import DNSOutgoing |
20 | 21 | from zeroconf._services import info
|
21 | 22 | from zeroconf._services.info import ServiceInfo
|
22 | 23 | from zeroconf._utils.net import IPVersion
|
@@ -1871,3 +1872,23 @@ async def test_address_resolver_ipv6():
|
1871 | 1872 | aiozc.zeroconf.async_send(outgoing)
|
1872 | 1873 | assert await resolve_task
|
1873 | 1874 | assert resolver.ip_addresses_by_version(IPVersion.All) == [ip_address("fe80::52e:c2f2:bc5f:e9c6")]
|
| 1875 | + |
| 1876 | + |
| 1877 | +@pytest.mark.asyncio |
| 1878 | +async def test_unicast_flag_if_requested() -> None: |
| 1879 | + """Verify we try four times even with the random delay.""" |
| 1880 | + type_ = "_typethatisnothere._tcp.local." |
| 1881 | + aiozc = AsyncZeroconf(interfaces=["127.0.0.1"]) |
| 1882 | + |
| 1883 | + def async_send(out: DNSOutgoing, addr: str | None = None, port: int = const._MDNS_PORT) -> None: |
| 1884 | + """Sends an outgoing packet.""" |
| 1885 | + for question in out.questions: |
| 1886 | + assert question.unicast |
| 1887 | + |
| 1888 | + # patch the zeroconf send |
| 1889 | + with patch.object(aiozc.zeroconf, "async_send", async_send): |
| 1890 | + await aiozc.async_get_service_info( |
| 1891 | + f"willnotbefound.{type_}", type_, question_type=r.DNSQuestionType.QU |
| 1892 | + ) |
| 1893 | + |
| 1894 | + await aiozc.async_close() |
0 commit comments