def testWordBoundryRegex(self): cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS, [BUILTIN_ISSUE_FIELDS['label']], ['Type-Bug'], []) regex = ast2ast._MakeKeyValueRegex(cond) self.assertRegexpMatches('Type-Bug-Security', regex) self.assertNotRegexpMatches('Type-BugSecurity', regex)
def testKeyValueRegex(self): cond = ast_pb2.MakeCond(ast_pb2.QueryOp.KEY_HAS, [BUILTIN_ISSUE_FIELDS['label']], ['Type-Feature', 'Type-Security'], []) regex = ast2ast._MakeKeyValueRegex(cond) self.assertRegexpMatches('Type-Feature', regex) self.assertRegexpMatches('Type-Bug-Security', regex) self.assertNotRegexpMatches('Type-Bug', regex) self.assertNotRegexpMatches('Security-Feature', regex)
def testKeyValueRegex_multipleKeys(self): cond = ast_pb2.MakeCond(ast_pb2.QueryOp.KEY_HAS, [BUILTIN_ISSUE_FIELDS['label']], ['Type-Bug', 'Security-Bug'], []) with self.assertRaises(ValueError): ast2ast._MakeKeyValueRegex(cond)