mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
9681372a84
@ -22,7 +22,7 @@ def validate_tree_name(value):
|
||||
|
||||
for c in "!@#$%^&*'\"\\/[]{}<>,|+=~`\"":
|
||||
if c in str(value):
|
||||
raise ValidationError({'name': _('Illegal character in name')})
|
||||
raise ValidationError(_('Illegal character in name ({x})'.format(x=c)))
|
||||
|
||||
|
||||
def validate_overage(value):
|
||||
|
@ -1,4 +1,5 @@
|
||||
from django.test import TestCase
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from .models import Part, PartCategory
|
||||
|
||||
@ -93,6 +94,20 @@ class CategoryTest(TestCase):
|
||||
|
||||
self.assertEqual(self.electronics.item_count, self.electronics.partcount())
|
||||
|
||||
def test_invalid_name(self):
|
||||
# Test that an illegal character is prohibited in a category name
|
||||
|
||||
cat = PartCategory(name='test/with/illegal/chars', description='Test category', parent=None)
|
||||
|
||||
with self.assertRaises(ValidationError) as err:
|
||||
cat.full_clean()
|
||||
cat.save()
|
||||
|
||||
self.assertIn('Illegal character in name', str(err.exception.error_dict.get('name')))
|
||||
|
||||
cat.name = 'good name'
|
||||
cat.save()
|
||||
|
||||
def test_delete(self):
|
||||
""" Test that category deletion moves the children properly """
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user