From f77e3c97eae654388c40d3b303c8a141d509aaa3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jun 2021 10:09:16 -1000 Subject: [PATCH] Add coverage for registering a service with a custom ttl --- tests/test_core.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_core.py b/tests/test_core.py index 6252488b..9c04d03d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -346,3 +346,28 @@ def test_goodbye_all_services(): assert zc.registry.get_service_infos() == [] zc.close() + + +def test_register_service_with_custom_ttl(): + """Test a registering a service with a custom ttl.""" + + # instantiate a zeroconf instance + zc = Zeroconf(interfaces=['127.0.0.1']) + + # start a browser + type_ = "_homeassistant._tcp.local." + name = "MyTestHome" + info_service = r.ServiceInfo( + type_, + '%s.%s' % (name, type_), + 80, + 0, + 0, + {'path': '/~paulsm/'}, + "ash-90.local.", + addresses=[socket.inet_aton("10.0.1.2")], + ) + + zc.register_service(info_service, ttl=30) + assert zc.cache.get(info_service.dns_pointer()).ttl == 30 + zc.close()