File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -606,6 +606,51 @@ def test_multiple_addresses():
606606 ]
607607
608608
609+ @unittest .skipIf (sys .version_info < (3 , 9 , 0 ), 'Requires newer python' )
610+ def test_scoped_addresses_from_cache ():
611+ type_ = "_http._tcp.local."
612+ registration_name = f"scoped.{ type_ } "
613+ zeroconf = r .Zeroconf (interfaces = ['127.0.0.1' ])
614+ host = "scoped.local."
615+
616+ zeroconf .cache .async_add_records (
617+ [
618+ r .DNSPointer (
619+ type_ ,
620+ const ._TYPE_PTR ,
621+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
622+ 120 ,
623+ registration_name ,
624+ ),
625+ r .DNSService (
626+ registration_name ,
627+ const ._TYPE_SRV ,
628+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
629+ 120 ,
630+ 0 ,
631+ 0 ,
632+ 80 ,
633+ host ,
634+ ),
635+ r .DNSAddress (
636+ host ,
637+ const ._TYPE_AAAA ,
638+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
639+ 120 ,
640+ socket .inet_pton (socket .AF_INET6 , "fe80::52e:c2f2:bc5f:e9c6" ),
641+ scope_id = 12 ,
642+ ),
643+ ]
644+ )
645+
646+ # New kwarg way
647+ info = ServiceInfo (type_ , registration_name )
648+ info .load_from_cache (zeroconf )
649+ assert info .parsed_scoped_addresses () == ["fe80::52e:c2f2:bc5f:e9c6%12" ]
650+ assert info .ip_addresses_by_version (r .IPVersion .V6Only ) == [ip_address ("fe80::52e:c2f2:bc5f:e9c6%12" )]
651+ zeroconf .close ()
652+
653+
609654# This test uses asyncio because it needs to access the cache directly
610655# which is not threadsafe
611656@pytest .mark .asyncio
You can’t perform that action at this time.
0 commit comments