From 07aa481ce5d821921b5d828bffd3446a0d556eae Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Tue, 3 Dec 2024 18:04:56 -0300 Subject: [PATCH] [chores] Moved and renamed test for #948 Related to #948 (cherry picked from commit 455144437b947fa343e39e0cea33ca997782f369) --- .../config/tests/test_template.py | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) 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()