diff --git a/openwisp_controller/config/tests/test_template.py b/openwisp_controller/config/tests/test_template.py index 1db5410d0..53540c6ea 100644 --- a/openwisp_controller/config/tests/test_template.py +++ b/openwisp_controller/config/tests/test_template.py @@ -501,6 +501,20 @@ def test_required_vpn_template_corner_case(self): # {'__all__': ['VPN client with this Config and Vpn already exists.']} self.assertIsNotNone(vpn_client) + def test_regression_preventing_from_fixing_invalid_conf(self): + template = self._create_template() + # create a template with an invalid configuration + Template.objects.update(config={'interfaces': [{'name': 'eth0', 'type': ''}]}) + # ensure the configuration raises ValidationError + with self.assertRaises(NetjsonconfigValidationError): + template.refresh_from_db() + del template.backend_instance + template.checksum + del template.backend_instance + template.config = {'interfaces': [{'name': 'eth0', 'type': 'ethernet'}]} + template.full_clean() + template.save() + class TestTemplateTransaction( TransactionTestMixin, @@ -734,18 +748,3 @@ def test_task_timeout(self, mocked_update_related_config_status): template.save() mocked_error.assert_called_once() mocked_update_related_config_status.assert_called_once() - - def test_fixing_wrong_configuration(self): - template = self._create_template() - # create a wrong configuration - Template.objects.update(config={'interfaces': [{'name': 'eth0', 'type': ''}]}) - # Ensure the configuration raises ValidationError - with self.assertRaises(NetjsonconfigValidationError): - template.refresh_from_db() - del template.backend_instance - template.checksum - - del template.backend_instance - template.config = {'interfaces': [{'name': 'eth0', 'type': 'ethernet'}]} - template.full_clean() - template.save()