Esempio n. 1
0
    def testPreprocessBlockedOnCond_WithMultipleProjectIDs_NoPrefix(self):
        blockedon_field = BUILTIN_ISSUE_FIELDS['blockedon']
        self.services.project.TestAddProject('Project1', project_id=1)
        self.services.project.TestAddProject('Project2', project_id=2)
        issue1 = fake.MakeTestIssue(project_id=1,
                                    local_id=1,
                                    summary='sum',
                                    status='new',
                                    owner_id=2,
                                    issue_id=101)
        issue2 = fake.MakeTestIssue(project_id=2,
                                    local_id=2,
                                    summary='sum',
                                    status='new',
                                    owner_id=2,
                                    issue_id=102)
        self.services.issue.TestAddIssue(issue1)
        self.services.issue.TestAddIssue(issue2)

        for local_ids in (['1'], ['1', '2'], ['3']):
            cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS,
                                    [blockedon_field], local_ids, [])
            with self.assertRaises(ValueError) as cm:
                ast2ast._PreprocessBlockedOnCond(self.cnxn, cond, [1, 2],
                                                 self.services, None, True)
            self.assertEquals(
                'Searching for issues accross multiple/all projects without '
                'project prefixes is ambiguous and is currently not supported.',
                cm.exception.message)
Esempio n. 2
0
    def testPreprocessBlockedOnCond_WithExternalIssues(self):
        blockedon_field = BUILTIN_ISSUE_FIELDS['blockedon']
        blockedon_id_field = BUILTIN_ISSUE_FIELDS['blockedon_id']
        self.services.project.TestAddProject('Project1', project_id=1)
        issue1 = fake.MakeTestIssue(project_id=1,
                                    local_id=1,
                                    summary='sum',
                                    status='new',
                                    owner_id=2,
                                    issue_id=101)
        issue2 = fake.MakeTestIssue(project_id=1,
                                    local_id=2,
                                    summary='sum',
                                    status='new',
                                    owner_id=2,
                                    issue_id=102)
        self.services.issue.TestAddIssue(issue1)
        self.services.issue.TestAddIssue(issue2)

        for local_ids, expected_issues, expected_ext_issues in (([
                'b/1234'
        ], [], ['b/1234']), (['Project1:1', 'b/1234'], [101],
                             ['b/1234'
                              ]), (['1', 'b/1234', 'b/1551',
                                    'Project1:2'], [101,
                                                    102], ['b/1234',
                                                           'b/1551'])):
            cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS,
                                    [blockedon_field], local_ids, [])
            new_cond = ast2ast._PreprocessBlockedOnCond(
                self.cnxn, cond, [1], self.services, None, True)
            self.assertEqual(ast_pb2.QueryOp.EQ, new_cond.op)
            self.assertEqual([blockedon_id_field], new_cond.field_defs)
            self.assertEqual(expected_issues, new_cond.int_values)
            self.assertEqual(expected_ext_issues, new_cond.str_values)
Esempio n. 3
0
    def testPreprocessBlockedOnCond_WithSingleProjectID(self):
        blockedon_field = BUILTIN_ISSUE_FIELDS['blockedon']
        blockedon_id_field = BUILTIN_ISSUE_FIELDS['blockedon_id']
        self.services.project.TestAddProject('Project1', project_id=1)
        issue1 = fake.MakeTestIssue(project_id=1,
                                    local_id=1,
                                    summary='sum',
                                    status='new',
                                    owner_id=2,
                                    issue_id=101)
        issue2 = fake.MakeTestIssue(project_id=1,
                                    local_id=2,
                                    summary='sum',
                                    status='new',
                                    owner_id=2,
                                    issue_id=102)
        self.services.issue.TestAddIssue(issue1)
        self.services.issue.TestAddIssue(issue2)

        for local_ids, expected in (
            (['1'], [101]),  # One existing issue.
            (['Project1:1'], [101]),  # One existing issue with project prefix.
            (['1', '2'], [101, 102]),  # Two existing issues.
            (['3'], [])):  # Non-existant issue.
            cond = ast_pb2.MakeCond(ast_pb2.QueryOp.TEXT_HAS,
                                    [blockedon_field], local_ids, [])
            new_cond = ast2ast._PreprocessBlockedOnCond(
                self.cnxn, cond, [1], self.services, None, True)
            self.assertEqual(ast_pb2.QueryOp.EQ, new_cond.op)
            self.assertEqual([blockedon_id_field], new_cond.field_defs)
            self.assertEqual(expected, new_cond.int_values)
            self.assertEqual([], new_cond.str_values)
Esempio n. 4
0
 def testPreprocessHasBlockedOnCond(self):
     blocked_field = BUILTIN_ISSUE_FIELDS['blockedon_id']
     for op in (ast_pb2.QueryOp.IS_DEFINED, ast_pb2.QueryOp.IS_NOT_DEFINED):
         cond = ast_pb2.MakeCond(op, [blocked_field], [], [])
         new_cond = ast2ast._PreprocessBlockedOnCond(
             self.cnxn, cond, [100], self.services, None, True)
         self.assertEqual(op, op)
         self.assertEqual([blocked_field], new_cond.field_defs)
         self.assertEqual([], new_cond.int_values)
         self.assertEqual([], new_cond.str_values)