def convert_issue_ids(issue_ids, mar, services): """Convert global issue ids to API IssueRef PB.""" # missed issue ids are filtered out. issues = services.issue.GetIssues(mar.cnxn, issue_ids) result = [] for issue in issues: issue_ref = api_pb2_v1.IssueRef(issueId=issue.local_id, projectId=issue.project_name, kind='monorail#issueRef') result.append(issue_ref) return result
def testConvertIssueRef(self): """Test convert_issueref_pbs.""" issue1 = fake.MakeTestIssue(12345, 1, 'one', 'New', 111) self.services.issue.TestAddIssue(issue1) self.services.project.TestAddProject('test-project', owner_ids=[2], project_id=12345) mar = mock.Mock() mar.cnxn = None mar.project_name = 'test-project' mar.project_id = 12345 ir = api_pb2_v1.IssueRef(issueId=1, projectId='test-project') result = api_pb2_v1_helpers.convert_issueref_pbs([ir], mar, self.services) self.assertEquals(1, len(result)) self.assertEquals(100001, result[0])