Skip to content

Commit adc6eab

Browse files
pandafynemesifier
authored andcommitted
[fix] Allow updating templates with invalid configurations
Previously, fixing an invalid template configuration via the UI was blocked due to the cache invalidation mechanism. This mechanism attempted to evaluate the existing configuration, triggering a ValidationError and preventing updates. (cherry picked from commit bd3d11a)
1 parent 07aa481 commit adc6eab

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

openwisp_controller/config/tests/test_template.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,3 +748,18 @@ def test_task_timeout(self, mocked_update_related_config_status):
748748
template.save()
749749
mocked_error.assert_called_once()
750750
mocked_update_related_config_status.assert_called_once()
751+
752+
def test_fixing_wrong_configuration(self):
753+
template = self._create_template()
754+
# create a wrong configuration
755+
Template.objects.update(config={'interfaces': [{'name': 'eth0', 'type': ''}]})
756+
# Ensure the configuration raises ValidationError
757+
with self.assertRaises(NetjsonconfigValidationError):
758+
template.refresh_from_db()
759+
del template.backend_instance
760+
template.checksum
761+
762+
del template.backend_instance
763+
template.config = {'interfaces': [{'name': 'eth0', 'type': 'ethernet'}]}
764+
template.full_clean()
765+
template.save()

0 commit comments

Comments
 (0)