@@ -433,6 +433,61 @@ def test_changing_group_variable_invalidates_cache(self):
433433 new_checksum = config .get_cached_checksum ()
434434 self .assertNotEqual (old_checksum , new_checksum )
435435
436+ def test_status_update_on_org_variable_change (self ):
437+ org = self ._get_org ()
438+ cs = OrganizationConfigSettings .objects .create (organization = org , context = {})
439+ c1 = self ._create_config (organization = org )
440+ c1 .templates .add (
441+ self ._create_template (
442+ name = "t-with-var" ,
443+ config = {"interfaces" : [{"name" : "eth0" , "type" : "{{ ssid }}" }]},
444+ default_values = {"ssid" : "default" },
445+ )
446+ )
447+ c1 .set_status_applied ()
448+ d2 = self ._create_device (
449+ organization = org , name = "d2" , mac_address = "00:11:22:33:44:56"
450+ )
451+ c2 = self ._create_config (device = d2 )
452+ c2 .set_status_applied ()
453+ cs .context = {"ssid" : "OrgA" }
454+ cs .full_clean ()
455+ cs .save ()
456+ c1 .refresh_from_db ()
457+ c2 .refresh_from_db ()
458+ with self .subTest ("affected config changes to modified" ):
459+ self .assertEqual (c1 .status , "modified" )
460+ with self .subTest ("unaffected config remains applied" ):
461+ self .assertEqual (c2 .status , "applied" )
462+
463+ def test_status_update_on_group_variable_change (self ):
464+ org = self ._get_org ()
465+ dg = self ._create_device_group (organization = org , context = {})
466+ d1 = self ._create_device (organization = org , group = dg )
467+ c1 = self ._create_config (device = d1 )
468+ c1 .templates .add (
469+ self ._create_template (
470+ name = "t-with-var" ,
471+ config = {"interfaces" : [{"name" : "eth0" , "type" : "{{ ssid }}" }]},
472+ default_values = {"ssid" : "default" },
473+ )
474+ )
475+ c1 .set_status_applied ()
476+ d2 = self ._create_device (
477+ organization = org , group = dg , name = "d2" , mac_address = "00:11:22:33:44:56"
478+ )
479+ c2 = self ._create_config (device = d2 )
480+ c2 .set_status_applied ()
481+ dg .context = {"ssid" : "OrgA" }
482+ dg .full_clean ()
483+ dg .save ()
484+ c1 .refresh_from_db ()
485+ c2 .refresh_from_db ()
486+ with self .subTest ("affected config changes to modified" ):
487+ self .assertEqual (c1 .status , "modified" )
488+ with self .subTest ("unaffected config remains applied" ):
489+ self .assertEqual (c2 .status , "applied" )
490+
436491 def test_management_ip_changed_not_emitted_on_creation (self ):
437492 with catch_signal (management_ip_changed ) as handler :
438493 self ._create_device (organization = self ._get_org ())
0 commit comments