Skip to content

Commit

Permalink
[chores] Moved and renamed test for #948
Browse files Browse the repository at this point in the history
Related to #948

(cherry picked from commit 4551444)
  • Loading branch information
nemesifier authored and pandafy committed Dec 4, 2024
1 parent bd44dd1 commit 07aa481
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions openwisp_controller/config/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

0 comments on commit 07aa481

Please sign in to comment.