Skip to content

Commit f77e3c9

Browse files
committed
Add coverage for registering a service with a custom ttl
1 parent efd6bfb commit f77e3c9

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/test_core.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,28 @@ def test_goodbye_all_services():
346346
assert zc.registry.get_service_infos() == []
347347

348348
zc.close()
349+
350+
351+
def test_register_service_with_custom_ttl():
352+
"""Test a registering a service with a custom ttl."""
353+
354+
# instantiate a zeroconf instance
355+
zc = Zeroconf(interfaces=['127.0.0.1'])
356+
357+
# start a browser
358+
type_ = "_homeassistant._tcp.local."
359+
name = "MyTestHome"
360+
info_service = r.ServiceInfo(
361+
type_,
362+
'%s.%s' % (name, type_),
363+
80,
364+
0,
365+
0,
366+
{'path': '/~paulsm/'},
367+
"ash-90.local.",
368+
addresses=[socket.inet_aton("10.0.1.2")],
369+
)
370+
371+
zc.register_service(info_service, ttl=30)
372+
assert zc.cache.get(info_service.dns_pointer()).ttl == 30
373+
zc.close()

0 commit comments

Comments
 (0)