@@ -394,6 +394,31 @@ def test_changing_org_variable_invalidates_cache(self):
394394 new_checksum = config .get_cached_checksum ()
395395 self .assertNotEqual (old_checksum , new_checksum )
396396
397+ def test_changing_group_variable_invalidates_cache (self ):
398+ org = self ._get_org ()
399+ device_group = self ._create_device_group (organization = org , context = {})
400+ device = self ._create_device (organization = org , group = device_group )
401+ config = self ._create_config (device = device )
402+ template = self ._create_template (
403+ config = {'interfaces' : [{'name' : 'eth0' , 'type' : '{{ interface_type }}' }]},
404+ default_values = {'interface_type' : 'ethernet' },
405+ )
406+ config .templates .add (template )
407+ old_checksum = config .get_cached_checksum ()
408+
409+ # Changing DeviceGroup.context should invalidate the cache
410+ # and a new checksum should be returned in the following request.
411+ device_group .context = {'interface_type' : 'virtual' }
412+ device_group .full_clean ()
413+ device_group .save ()
414+
415+ # Config.backend_instance is a "cached_property", hence deleting
416+ # the attribute is required for testing.
417+ del config .backend_instance
418+
419+ new_checksum = config .get_cached_checksum ()
420+ self .assertNotEqual (old_checksum , new_checksum )
421+
397422 def test_management_ip_changed_not_emitted_on_creation (self ):
398423 with catch_signal (management_ip_changed ) as handler :
399424 self ._create_device (organization = self ._get_org ())
0 commit comments