mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
12468 disallow double underscores in custom field names (#12523)
* 12468 disallow double underscores in custom field names * 12468 disallow double underscores in custom field names * 12468 review changes * 12468 correct migration * 12468 use inverse match * 12468 use inverse match * Add test for invalid custom field names --------- Co-authored-by: jeremystretch <jstretch@netboxlabs.com>
This commit is contained in:
@@ -29,6 +29,17 @@ class CustomFieldTest(TestCase):
|
||||
|
||||
cls.object_type = ContentType.objects.get_for_model(Site)
|
||||
|
||||
def test_invalid_name(self):
|
||||
"""
|
||||
Try creating a CustomField with an invalid name.
|
||||
"""
|
||||
with self.assertRaises(ValidationError):
|
||||
# Invalid character
|
||||
CustomField(name='?', type=CustomFieldTypeChoices.TYPE_TEXT).full_clean()
|
||||
with self.assertRaises(ValidationError):
|
||||
# Double underscores not permitted
|
||||
CustomField(name='foo__bar', type=CustomFieldTypeChoices.TYPE_TEXT).full_clean()
|
||||
|
||||
def test_text_field(self):
|
||||
value = 'Foobar!'
|
||||
|
||||
|
Reference in New Issue
Block a user