mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Improve validation
This commit is contained in:
@@ -16,6 +16,25 @@ class ConditionTestCase(TestCase):
|
||||
self.assertFalse(c.eval({}))
|
||||
self.assertTrue(c.eval({'x': 1}))
|
||||
|
||||
#
|
||||
# Validation tests
|
||||
#
|
||||
|
||||
def test_invalid_op(self):
|
||||
with self.assertRaises(ValueError):
|
||||
# 'blah' is not a valid operator
|
||||
Condition('x', 1, 'blah')
|
||||
|
||||
def test_invalid_type(self):
|
||||
with self.assertRaises(ValueError):
|
||||
# dict type is unsupported
|
||||
Condition('x', 1, dict())
|
||||
|
||||
def test_invalid_op_type(self):
|
||||
with self.assertRaises(ValueError):
|
||||
# 'gt' supports only numeric values
|
||||
Condition('x', 'foo', 'gt')
|
||||
|
||||
#
|
||||
# Operator tests
|
||||
#
|
||||
|
Reference in New Issue
Block a user