1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add regex condition op

This commit is contained in:
jeremystretch
2021-10-25 10:14:18 -04:00
parent 2423e0872f
commit 0d84338e28
2 changed files with 19 additions and 2 deletions

View File

@@ -95,6 +95,16 @@ class ConditionTestCase(TestCase):
self.assertFalse(c.eval({'x': [1, 2, 3]}))
self.assertTrue(c.eval({'x': [2, 3, 4]}))
def test_regex(self):
c = Condition('x', '[a-z]+', 'regex')
self.assertTrue(c.eval({'x': 'abc'}))
self.assertFalse(c.eval({'x': '123'}))
def test_regex_negated(self):
c = Condition('x', '[a-z]+', 'regex', negate=True)
self.assertFalse(c.eval({'x': 'abc'}))
self.assertTrue(c.eval({'x': '123'}))
class ConditionSetTest(TestCase):