Skip to content

Commit dd22513

Browse files
committed
[tests] Fixed failure in test_change_device_clean_templates
After fixing openwisp/netjsonconfig#197 This admin test in the config app was not failing anymore because the failure case is now handled automatically in netjsonconfig. Rather than looking for another cases needed to trigger the error I simulated the error with mocking to ensure the UI will continue handling any error in such cases.
1 parent ddc9999 commit dd22513

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

openwisp_controller/config/tests/test_admin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.contrib.admin.models import LogEntry
66
from django.contrib.auth import get_user_model
7+
from django.core.exceptions import ValidationError
78
from django.test import TestCase
89
from django.urls import reverse
910
from swapper import load_model
@@ -489,7 +490,10 @@ def test_change_device_clean_templates(self):
489490
}
490491
)
491492
# ensure it fails with error
492-
response = self.client.post(path, params)
493+
with patch.object(
494+
Config, 'clean_templates', side_effect=ValidationError('test')
495+
):
496+
response = self.client.post(path, params)
493497
self.assertContains(response, 'errors field-templates')
494498
# remove conflicting template and ensure doesn't error
495499
params['config-0-templates'] = ''

0 commit comments

Comments
 (0)