def testPreprocessCustomCond_User(self): fd = tracker_pb2.FieldDef(field_id=1, field_name='TPM', field_type=tracker_pb2.FieldTypes.USER_TYPE) cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS, [fd], ['*****@*****.**'], []) new_cond = ast2ast._PreprocessCustomCond(self.cnxn, cond, self.services, True) self.assertEqual(ast_pb2.QueryOp.EQ, new_cond.op) self.assertEqual(cond.field_defs, new_cond.field_defs) self.assertEqual([111], new_cond.int_values) self.assertEqual([], new_cond.str_values) cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS, [fd], ['111'], []) new_cond = ast2ast._PreprocessCustomCond(self.cnxn, cond, self.services, True) self.assertEqual(ast_pb2.QueryOp.EQ, new_cond.op) self.assertEqual(cond.field_defs, new_cond.field_defs) self.assertEqual([111], new_cond.int_values) self.assertEqual([], new_cond.str_values) cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS, [fd], ['*****@*****.**'], []) new_cond = ast2ast._PreprocessCustomCond(self.cnxn, cond, self.services, True) self.assertEqual(cond, new_cond)
def testPreprocessCustomCond_NonUser(self): fd = tracker_pb2.FieldDef(field_id=1, field_name='TPM', field_type=tracker_pb2.FieldTypes.INT_TYPE) cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS, [fd], ['foo'], [123]) new_cond = ast2ast._PreprocessCustomCond(self.cnxn, cond, self.services, True) self.assertEqual(cond, new_cond) fd.field_type = tracker_pb2.FieldTypes.STR_TYPE new_cond = ast2ast._PreprocessCustomCond(self.cnxn, cond, self.services, True) self.assertEqual(cond, new_cond)
def testPreprocessCustomCond_ApprovalUser(self): fd = tracker_pb2.FieldDef( field_id=1, field_name='UXReview', field_type=tracker_pb2.FieldTypes.APPROVAL_TYPE) cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS, [fd], ['*****@*****.**'], [], key_suffix=query2ast.APPROVER_SUFFIX) new_cond = ast2ast._PreprocessCustomCond(self.cnxn, cond, self.services, True) self.assertEqual(ast_pb2.QueryOp.EQ, new_cond.op) self.assertEqual(cond.field_defs, new_cond.field_defs) self.assertEqual([111], new_cond.int_values) self.assertEqual([], new_cond.str_values) self.assertEqual(query2ast.APPROVER_SUFFIX, new_cond.key_suffix)