1717import pytest
1818
1919import zeroconf as r
20- from zeroconf import DNSAddress , const
20+ from zeroconf import DNSAddress , RecordUpdate , const
2121from zeroconf ._services import info
2222from zeroconf ._services .info import ServiceInfo
2323from zeroconf ._utils .net import IPVersion
@@ -68,89 +68,119 @@ def test_service_info_rejects_non_matching_updates(self):
6868 service_type , service_name , 22 , 0 , 0 , desc , service_server , addresses = [service_address ]
6969 )
7070 # Verify backwards compatiblity with calling with None
71- info .update_record (zc , now , None )
71+ info .async_update_records (zc , now , [] )
7272 # Matching updates
73- info .update_record (
73+ info .async_update_records (
7474 zc ,
7575 now ,
76- r .DNSText (
77- service_name ,
78- const ._TYPE_TXT ,
79- const ._CLASS_IN | const ._CLASS_UNIQUE ,
80- ttl ,
81- b'\x04 ff=0\x04 ci=2\x04 sf=0\x0b sh=6fLM5A==' ,
82- ),
76+ [
77+ RecordUpdate (
78+ r .DNSText (
79+ service_name ,
80+ const ._TYPE_TXT ,
81+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
82+ ttl ,
83+ b'\x04 ff=0\x04 ci=2\x04 sf=0\x0b sh=6fLM5A==' ,
84+ ),
85+ None ,
86+ )
87+ ],
8388 )
8489 assert info .properties [b"ci" ] == b"2"
85- info .update_record (
90+ info .async_update_records (
8691 zc ,
8792 now ,
88- r .DNSService (
89- service_name ,
90- const ._TYPE_SRV ,
91- const ._CLASS_IN | const ._CLASS_UNIQUE ,
92- ttl ,
93- 0 ,
94- 0 ,
95- 80 ,
96- 'ASH-2.local.' ,
97- ),
93+ [
94+ RecordUpdate (
95+ r .DNSService (
96+ service_name ,
97+ const ._TYPE_SRV ,
98+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
99+ ttl ,
100+ 0 ,
101+ 0 ,
102+ 80 ,
103+ 'ASH-2.local.' ,
104+ ),
105+ None ,
106+ )
107+ ],
98108 )
99109 assert info .server_key == 'ash-2.local.'
100110 assert info .server == 'ASH-2.local.'
101111 new_address = socket .inet_aton ("10.0.1.3" )
102- info .update_record (
112+ info .async_update_records (
103113 zc ,
104114 now ,
105- r .DNSAddress (
106- 'ASH-2.local.' ,
107- const ._TYPE_A ,
108- const ._CLASS_IN | const ._CLASS_UNIQUE ,
109- ttl ,
110- new_address ,
111- ),
115+ [
116+ RecordUpdate (
117+ r .DNSAddress (
118+ 'ASH-2.local.' ,
119+ const ._TYPE_A ,
120+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
121+ ttl ,
122+ new_address ,
123+ ),
124+ None ,
125+ )
126+ ],
112127 )
113128 assert new_address in info .addresses
114129 # Non-matching updates
115- info .update_record (
130+ info .async_update_records (
116131 zc ,
117132 now ,
118- r .DNSText (
119- "incorrect.name." ,
120- const ._TYPE_TXT ,
121- const ._CLASS_IN | const ._CLASS_UNIQUE ,
122- ttl ,
123- b'\x04 ff=0\x04 ci=3\x04 sf=0\x0b sh=6fLM5A==' ,
124- ),
133+ [
134+ RecordUpdate (
135+ r .DNSText (
136+ "incorrect.name." ,
137+ const ._TYPE_TXT ,
138+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
139+ ttl ,
140+ b'\x04 ff=0\x04 ci=3\x04 sf=0\x0b sh=6fLM5A==' ,
141+ ),
142+ None ,
143+ )
144+ ],
125145 )
126146 assert info .properties [b"ci" ] == b"2"
127- info .update_record (
147+ info .async_update_records (
128148 zc ,
129149 now ,
130- r .DNSService (
131- "incorrect.name." ,
132- const ._TYPE_SRV ,
133- const ._CLASS_IN | const ._CLASS_UNIQUE ,
134- ttl ,
135- 0 ,
136- 0 ,
137- 80 ,
138- 'ASH-2.local.' ,
139- ),
150+ [
151+ RecordUpdate (
152+ r .DNSService (
153+ "incorrect.name." ,
154+ const ._TYPE_SRV ,
155+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
156+ ttl ,
157+ 0 ,
158+ 0 ,
159+ 80 ,
160+ 'ASH-2.local.' ,
161+ ),
162+ None ,
163+ )
164+ ],
140165 )
141166 assert info .server_key == 'ash-2.local.'
142167 assert info .server == 'ASH-2.local.'
143168 new_address = socket .inet_aton ("10.0.1.4" )
144- info .update_record (
169+ info .async_update_records (
145170 zc ,
146171 now ,
147- r .DNSAddress (
148- "incorrect.name." ,
149- const ._TYPE_A ,
150- const ._CLASS_IN | const ._CLASS_UNIQUE ,
151- ttl ,
152- new_address ,
153- ),
172+ [
173+ RecordUpdate (
174+ r .DNSAddress (
175+ "incorrect.name." ,
176+ const ._TYPE_A ,
177+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
178+ ttl ,
179+ new_address ,
180+ ),
181+ None ,
182+ )
183+ ],
154184 )
155185 assert new_address not in info .addresses
156186 zc .close ()
@@ -169,16 +199,21 @@ def test_service_info_rejects_expired_records(self):
169199 service_type , service_name , 22 , 0 , 0 , desc , service_server , addresses = [service_address ]
170200 )
171201 # Matching updates
172- info .update_record (
202+ info .async_update_records (
173203 zc ,
174204 now ,
175- r .DNSText (
176- service_name ,
177- const ._TYPE_TXT ,
178- const ._CLASS_IN | const ._CLASS_UNIQUE ,
179- ttl ,
180- b'\x04 ff=0\x04 ci=2\x04 sf=0\x0b sh=6fLM5A==' ,
181- ),
205+ [
206+ RecordUpdate (
207+ r .DNSText (
208+ service_name ,
209+ const ._TYPE_TXT ,
210+ const ._CLASS_IN | const ._CLASS_UNIQUE ,
211+ ttl ,
212+ b'\x04 ff=0\x04 ci=2\x04 sf=0\x0b sh=6fLM5A==' ,
213+ ),
214+ None ,
215+ )
216+ ],
182217 )
183218 assert info .properties [b"ci" ] == b"2"
184219 # Expired record
@@ -190,7 +225,7 @@ def test_service_info_rejects_expired_records(self):
190225 b'\x04 ff=0\x04 ci=3\x04 sf=0\x0b sh=6fLM5A==' ,
191226 )
192227 expired_record .set_created_ttl (1000 , 1 )
193- info .update_record (zc , now , expired_record )
228+ info .async_update_records (zc , now , [ RecordUpdate ( expired_record , None )] )
194229 assert info .properties [b"ci" ] == b"2"
195230 zc .close ()
196231
0 commit comments