@@ -2279,6 +2279,36 @@ def test_templates_fetch_queries_10(self):
22792279 config = self ._create_config (organization = self ._get_org ())
22802280 self ._verify_template_queries (config , 10 )
22812281
2282+ def test_empty_device_form_with_config_inline (self ):
2283+ org = self ._get_org ()
2284+ template = self ._create_template (organization = org )
2285+ path = reverse (f"admin:{ self .app_label } _device_add" )
2286+ # Submit form without required device fields but with config inline
2287+ # This reproduces the scenario where user clicks "Add another Configuration"
2288+ # and submits without filling device details
2289+ params = {
2290+ "config-0-backend" : "netjsonconfig.OpenWrt" ,
2291+ "config-0-templates" : str (template .pk ),
2292+ "config-0-config" : json .dumps ({}),
2293+ "config-0-context" : "" ,
2294+ "config-TOTAL_FORMS" : 1 ,
2295+ "config-INITIAL_FORMS" : 0 ,
2296+ "config-MIN_NUM_FORMS" : 0 ,
2297+ "config-MAX_NUM_FORMS" : 1 ,
2298+ "deviceconnection_set-TOTAL_FORMS" : 0 ,
2299+ "deviceconnection_set-INITIAL_FORMS" : 0 ,
2300+ "deviceconnection_set-MIN_NUM_FORMS" : 0 ,
2301+ "deviceconnection_set-MAX_NUM_FORMS" : 1000 ,
2302+ "command_set-TOTAL_FORMS" : 0 ,
2303+ "command_set-INITIAL_FORMS" : 0 ,
2304+ "command_set-MIN_NUM_FORMS" : 0 ,
2305+ "command_set-MAX_NUM_FORMS" : 1000 ,
2306+ }
2307+ response = self .client .post (path , params )
2308+ self .assertEqual (response .status_code , 200 )
2309+ self .assertContains (response , "errorlist" )
2310+ self .assertEqual (Device .objects .count (), 0 )
2311+
22822312
22832313class TestTransactionAdmin (
22842314 CreateConfigTemplateMixin ,
0 commit comments