mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add unit test for invalid characters
This commit is contained in:
parent
844f337d64
commit
8716281f7e
@ -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