def validate_rule(rule): """Validate Trigger-Rule.""" i = TRIGGER_EXPR.match(rule) if i is None: return None ret = [i.group(1), i.group(2), i.group(3), i.group(4)] return ret
def test_trigger_regexp(self): ret = TRIGGER_EXPR.match("last() > 0") self.assertNotEqual(ret, None) self.assertEqual(ret.group(1), "last") self.assertEqual(ret.group(2), "") self.assertEqual(ret.group(3), ">") self.assertEqual(ret.group(4), "0") ret = TRIGGER_EXPR.match("last() > 0.0") self.assertNotEqual(ret, None) self.assertEqual(ret.group(1), "last") self.assertEqual(ret.group(2), "") self.assertEqual(ret.group(3), ">") self.assertEqual(ret.group(4), "0.0") ret = TRIGGER_EXPR.match("last() > 10") self.assertNotEqual(ret, None) self.assertEqual(ret.group(1), "last") self.assertEqual(ret.group(2), "") self.assertEqual(ret.group(3), ">") self.assertEqual(ret.group(4), "10")