mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Merge pull request #516 from SchrodingersGat/tree-name-fix
Tree name fix
This commit is contained in:
		| @@ -22,7 +22,7 @@ def validate_tree_name(value): | |||||||
|  |  | ||||||
|     for c in "!@#$%^&*'\"\\/[]{}<>,|+=~`\"": |     for c in "!@#$%^&*'\"\\/[]{}<>,|+=~`\"": | ||||||
|         if c in str(value): |         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): | def validate_overage(value): | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| from django.test import TestCase | from django.test import TestCase | ||||||
|  | from django.core.exceptions import ValidationError | ||||||
|  |  | ||||||
| from .models import Part, PartCategory | from .models import Part, PartCategory | ||||||
|  |  | ||||||
| @@ -93,6 +94,20 @@ class CategoryTest(TestCase): | |||||||
|  |  | ||||||
|         self.assertEqual(self.electronics.item_count, self.electronics.partcount()) |         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): |     def test_delete(self): | ||||||
|         """ Test that category deletion moves the children properly """ |         """ Test that category deletion moves the children properly """ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user