mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-15 00:02:17 -06:00
Update test
This commit is contained in:
@@ -1506,19 +1506,18 @@ class CustomFieldModelTest(TestCase):
|
|||||||
|
|
||||||
def test_invalid_data(self):
|
def test_invalid_data(self):
|
||||||
"""
|
"""
|
||||||
Setting custom field data for a non-applicable (or non-existent) CustomField should raise a ValidationError.
|
Any invalid or stale custom field data should be removed from the instance.
|
||||||
"""
|
"""
|
||||||
site = Site(name='Test Site', slug='test-site')
|
site = Site(name='Test Site', slug='test-site')
|
||||||
|
|
||||||
# Set custom field data
|
# Set custom field data
|
||||||
site.custom_field_data['foo'] = 'abc'
|
site.custom_field_data['foo'] = 'abc'
|
||||||
site.custom_field_data['bar'] = 'def'
|
site.custom_field_data['bar'] = 'def'
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
site.clean()
|
|
||||||
|
|
||||||
del site.custom_field_data['bar']
|
|
||||||
site.clean()
|
site.clean()
|
||||||
|
|
||||||
|
self.assertIn('foo', site.custom_field_data)
|
||||||
|
self.assertNotIn('bar', site.custom_field_data)
|
||||||
|
|
||||||
def test_missing_required_field(self):
|
def test_missing_required_field(self):
|
||||||
"""
|
"""
|
||||||
Check that a ValidationError is raised if any required custom fields are not present.
|
Check that a ValidationError is raised if any required custom fields are not present.
|
||||||
|
|||||||
Reference in New Issue
Block a user