@@ -142,27 +142,39 @@ def test_valid_ipv4_passes_clean(self, db):
142142 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
143143
144144 defn = OptionDefinition .objects .create (
145- name = "routers" , code = 3 , option_type = "ipv4-address" ,
146- option_space = "dhcp4" , is_standard = True ,
145+ name = "routers" ,
146+ code = 3 ,
147+ option_type = "ipv4-address" ,
148+ option_space = "dhcp4" ,
149+ is_standard = True ,
147150 )
148151 opt = OptionData (
149- distinctive_name = "test-routers" , definition = defn ,
150- option_space = "dhcp4" , delivery_type = "standard" ,
151- data = "192.168.1.1" , csv_format = True ,
152+ distinctive_name = "test-routers" ,
153+ definition = defn ,
154+ option_space = "dhcp4" ,
155+ delivery_type = "standard" ,
156+ data = "192.168.1.1" ,
157+ csv_format = True ,
152158 )
153159 opt .clean () # should not raise
154160
155161 def test_invalid_ipv4_fails_clean (self , db ):
156162 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
157163
158164 defn = OptionDefinition .objects .create (
159- name = "routers" , code = 3 , option_type = "ipv4-address" ,
160- option_space = "dhcp4" , is_standard = True ,
165+ name = "routers" ,
166+ code = 3 ,
167+ option_type = "ipv4-address" ,
168+ option_space = "dhcp4" ,
169+ is_standard = True ,
161170 )
162171 opt = OptionData (
163- distinctive_name = "test-bad-router" , definition = defn ,
164- option_space = "dhcp4" , delivery_type = "standard" ,
165- data = "not-an-ip" , csv_format = True ,
172+ distinctive_name = "test-bad-router" ,
173+ definition = defn ,
174+ option_space = "dhcp4" ,
175+ delivery_type = "standard" ,
176+ data = "not-an-ip" ,
177+ csv_format = True ,
166178 )
167179 with pytest .raises (ValidationError , match = "valid IPv4" ):
168180 opt .clean ()
@@ -171,27 +183,41 @@ def test_array_ipv4_valid(self, db):
171183 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
172184
173185 defn = OptionDefinition .objects .create (
174- name = "ntp-servers" , code = 42 , option_type = "ipv4-address" ,
175- option_space = "dhcp4" , is_standard = True , is_array = True ,
186+ name = "ntp-servers" ,
187+ code = 42 ,
188+ option_type = "ipv4-address" ,
189+ option_space = "dhcp4" ,
190+ is_standard = True ,
191+ is_array = True ,
176192 )
177193 opt = OptionData (
178- distinctive_name = "test-ntp" , definition = defn ,
179- option_space = "dhcp4" , delivery_type = "standard" ,
180- data = "8.8.8.8, 8.8.4.4" , csv_format = True ,
194+ distinctive_name = "test-ntp" ,
195+ definition = defn ,
196+ option_space = "dhcp4" ,
197+ delivery_type = "standard" ,
198+ data = "8.8.8.8, 8.8.4.4" ,
199+ csv_format = True ,
181200 )
182201 opt .clean () # should not raise
183202
184203 def test_array_ipv4_one_invalid (self , db ):
185204 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
186205
187206 defn = OptionDefinition .objects .create (
188- name = "ntp-servers" , code = 42 , option_type = "ipv4-address" ,
189- option_space = "dhcp4" , is_standard = True , is_array = True ,
207+ name = "ntp-servers" ,
208+ code = 42 ,
209+ option_type = "ipv4-address" ,
210+ option_space = "dhcp4" ,
211+ is_standard = True ,
212+ is_array = True ,
190213 )
191214 opt = OptionData (
192- distinctive_name = "test-ntp-bad" , definition = defn ,
193- option_space = "dhcp4" , delivery_type = "standard" ,
194- data = "8.8.8.8, not-an-ip" , csv_format = True ,
215+ distinctive_name = "test-ntp-bad" ,
216+ definition = defn ,
217+ option_space = "dhcp4" ,
218+ delivery_type = "standard" ,
219+ data = "8.8.8.8, not-an-ip" ,
220+ csv_format = True ,
195221 )
196222 with pytest .raises (ValidationError , match = "valid IPv4" ):
197223 opt .clean ()
@@ -200,13 +226,20 @@ def test_single_value_rejects_comma_separated(self, db):
200226 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
201227
202228 defn = OptionDefinition .objects .create (
203- name = "routers" , code = 3 , option_type = "ipv4-address" ,
204- option_space = "dhcp4" , is_standard = True , is_array = False ,
229+ name = "routers" ,
230+ code = 3 ,
231+ option_type = "ipv4-address" ,
232+ option_space = "dhcp4" ,
233+ is_standard = True ,
234+ is_array = False ,
205235 )
206236 opt = OptionData (
207- distinctive_name = "test-multi-single" , definition = defn ,
208- option_space = "dhcp4" , delivery_type = "standard" ,
209- data = "192.168.1.1, 192.168.1.2" , csv_format = True ,
237+ distinctive_name = "test-multi-single" ,
238+ definition = defn ,
239+ option_space = "dhcp4" ,
240+ delivery_type = "standard" ,
241+ data = "192.168.1.1, 192.168.1.2" ,
242+ csv_format = True ,
210243 )
211244 with pytest .raises (ValidationError , match = "does not accept multiple values" ):
212245 opt .clean ()
@@ -216,13 +249,19 @@ def test_hex_data_skips_type_validation(self, db):
216249 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
217250
218251 defn = OptionDefinition .objects .create (
219- name = "custom-opt" , code = 100 , option_type = "ipv4-address" ,
220- option_space = "dhcp4" , is_standard = False ,
252+ name = "custom-opt" ,
253+ code = 100 ,
254+ option_type = "ipv4-address" ,
255+ option_space = "dhcp4" ,
256+ is_standard = False ,
221257 )
222258 opt = OptionData (
223- distinctive_name = "test-hex" , definition = defn ,
224- option_space = "dhcp4" , delivery_type = "standard" ,
225- data = "C0A80101" , csv_format = False , # hex for 192.168.1.1
259+ distinctive_name = "test-hex" ,
260+ definition = defn ,
261+ option_space = "dhcp4" ,
262+ delivery_type = "standard" ,
263+ data = "C0A80101" ,
264+ csv_format = False , # hex for 192.168.1.1
226265 )
227266 opt .clean () # should not raise — hex validation only, not IP format
228267
@@ -231,9 +270,12 @@ def test_no_definition_skips_type_validation(self, db):
231270 from netbox_dhcp_kea_plugin .models import OptionData
232271
233272 opt = OptionData (
234- distinctive_name = "test-no-def" , definition = None ,
235- option_space = "dhcp4" , delivery_type = "standard" ,
236- data = "anything" , csv_format = True ,
273+ distinctive_name = "test-no-def" ,
274+ definition = None ,
275+ option_space = "dhcp4" ,
276+ delivery_type = "standard" ,
277+ data = "anything" ,
278+ csv_format = True ,
237279 )
238280 opt .clean () # should not raise
239281
@@ -242,41 +284,59 @@ def test_empty_data_skips_type_validation(self, db):
242284 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
243285
244286 defn = OptionDefinition .objects .create (
245- name = "empty-opt" , code = 101 , option_type = "ipv4-address" ,
246- option_space = "dhcp4" , is_standard = False ,
287+ name = "empty-opt" ,
288+ code = 101 ,
289+ option_type = "ipv4-address" ,
290+ option_space = "dhcp4" ,
291+ is_standard = False ,
247292 )
248293 opt = OptionData (
249- distinctive_name = "test-empty" , definition = defn ,
250- option_space = "dhcp4" , delivery_type = "standard" ,
251- data = "" , csv_format = True ,
294+ distinctive_name = "test-empty" ,
295+ definition = defn ,
296+ option_space = "dhcp4" ,
297+ delivery_type = "standard" ,
298+ data = "" ,
299+ csv_format = True ,
252300 )
253301 opt .clean () # should not raise
254302
255303 def test_uint16_valid_in_clean (self , db ):
256304 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
257305
258306 defn = OptionDefinition .objects .create (
259- name = "mtu" , code = 26 , option_type = "uint16" ,
260- option_space = "dhcp4" , is_standard = True ,
307+ name = "mtu" ,
308+ code = 26 ,
309+ option_type = "uint16" ,
310+ option_space = "dhcp4" ,
311+ is_standard = True ,
261312 )
262313 opt = OptionData (
263- distinctive_name = "test-mtu" , definition = defn ,
264- option_space = "dhcp4" , delivery_type = "standard" ,
265- data = "1500" , csv_format = True ,
314+ distinctive_name = "test-mtu" ,
315+ definition = defn ,
316+ option_space = "dhcp4" ,
317+ delivery_type = "standard" ,
318+ data = "1500" ,
319+ csv_format = True ,
266320 )
267321 opt .clean () # should not raise
268322
269323 def test_uint16_invalid_in_clean (self , db ):
270324 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
271325
272326 defn = OptionDefinition .objects .create (
273- name = "mtu-bad" , code = 26 , option_type = "uint16" ,
274- option_space = "dhcp4" , is_standard = True ,
327+ name = "mtu-bad" ,
328+ code = 26 ,
329+ option_type = "uint16" ,
330+ option_space = "dhcp4" ,
331+ is_standard = True ,
275332 )
276333 opt = OptionData (
277- distinctive_name = "test-mtu-bad" , definition = defn ,
278- option_space = "dhcp4" , delivery_type = "standard" ,
279- data = "70000" , csv_format = True ,
334+ distinctive_name = "test-mtu-bad" ,
335+ definition = defn ,
336+ option_space = "dhcp4" ,
337+ delivery_type = "standard" ,
338+ data = "70000" ,
339+ csv_format = True ,
280340 )
281341 with pytest .raises (ValidationError , match = "between 0 and 65535" ):
282342 opt .clean ()
@@ -285,12 +345,18 @@ def test_boolean_valid_in_clean(self, db):
285345 from netbox_dhcp_kea_plugin .models import OptionData , OptionDefinition
286346
287347 defn = OptionDefinition .objects .create (
288- name = "ip-forwarding" , code = 19 , option_type = "boolean" ,
289- option_space = "dhcp4" , is_standard = True ,
348+ name = "ip-forwarding" ,
349+ code = 19 ,
350+ option_type = "boolean" ,
351+ option_space = "dhcp4" ,
352+ is_standard = True ,
290353 )
291354 opt = OptionData (
292- distinctive_name = "test-fwd" , definition = defn ,
293- option_space = "dhcp4" , delivery_type = "standard" ,
294- data = "true" , csv_format = True ,
355+ distinctive_name = "test-fwd" ,
356+ definition = defn ,
357+ option_space = "dhcp4" ,
358+ delivery_type = "standard" ,
359+ data = "true" ,
360+ csv_format = True ,
295361 )
296362 opt .clean () # should not raise
0 commit comments