Merge branch 'main' into avm99963-monorail
Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266
GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/api/test/issues_servicer_test.py b/api/test/issues_servicer_test.py
index 0ba50ac..ab35a9f 100644
--- a/api/test/issues_servicer_test.py
+++ b/api/test/issues_servicer_test.py
@@ -1,7 +1,6 @@
-# Copyright 2018 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2018 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
"""Tests for the issues servicer."""
from __future__ import print_function
@@ -33,13 +32,12 @@
from framework import monorailcontext
from framework import permissions
from search import frontendsearchpipeline
-from proto import tracker_pb2
-from proto import project_pb2
+from mrproto import tracker_pb2
+from mrproto import project_pb2
from testing import fake
from tracker import tracker_bizobj
from services import service_manager
-from proto import tracker_pb2
-
+from mrproto import tracker_pb2
class IssuesServicerTest(unittest.TestCase):
@@ -68,7 +66,7 @@
self.issue_2 = fake.MakeTestIssue(
789, 2, 'sum', 'New', 111, project_name='proj', issue_id=1002)
self.issue_1.blocked_on_iids.append(self.issue_2.issue_id)
- self.issue_1.blocked_on_ranks.append(sys.maxint)
+ self.issue_1.blocked_on_ranks.append(sys.maxsize)
self.services.issue.TestAddIssue(self.issue_1)
self.services.issue.TestAddIssue(self.issue_2)
self.issues_svcr = issues_servicer.IssuesServicer(
@@ -161,8 +159,10 @@
self.assertEqual('proj', response.project_name)
- def testGetIssue_Normal(self):
+ @patch('businesslogic.work_env.WorkEnv.GetIssueMigratedID')
+ def testGetIssue_Normal(self, mockGetIssueMigratedID):
"""We can get an issue."""
+ mockGetIssueMigratedID.return_value = None
request = issues_pb2.GetIssueRequest()
request.issue_ref.project_name = 'proj'
request.issue_ref.local_id = 1
@@ -179,6 +179,27 @@
self.assertEqual('proj', actual.blocked_on_issue_refs[0].project_name)
self.assertEqual(2, actual.blocked_on_issue_refs[0].local_id)
+ @patch('businesslogic.work_env.WorkEnv.GetIssueMigratedID')
+ def testGetIssue_WithMigratedID(self, mockGetIssueMigratedID):
+ """We can get an issue."""
+ mockGetIssueMigratedID.return_value = '123'
+ request = issues_pb2.GetIssueRequest()
+ request.issue_ref.project_name = 'proj'
+ request.issue_ref.local_id = 1
+ mc = monorailcontext.MonorailContext(
+ self.services, cnxn=self.cnxn, requester='owner@example.com')
+ mc.LookupLoggedInUserPerms(self.project)
+
+ response = self.CallWrapped(self.issues_svcr.GetIssue, mc, request)
+
+ actual = response.issue
+ self.assertEqual('proj', actual.project_name)
+ self.assertEqual(1, actual.local_id)
+ self.assertEqual(1, len(actual.blocked_on_issue_refs))
+ self.assertEqual('proj', actual.blocked_on_issue_refs[0].project_name)
+ self.assertEqual(2, actual.blocked_on_issue_refs[0].local_id)
+ self.assertEqual('123', actual.migrated_id)
+
def testGetIssue_Moved(self):
"""We can get a moved issue."""
self.services.project.TestAddProject(
@@ -560,10 +581,11 @@
request.issue_ref.project_name = 'proj'
request.issue_ref.local_id = 1
request.comment_content = 'test comment'
- request.uploads.extend([
- issue_objects_pb2.AttachmentUpload(
- filename='a.txt',
- content='aaaaa')])
+ request.uploads.extend(
+ [
+ issue_objects_pb2.AttachmentUpload(
+ filename='a.txt', content=b'aaaaa')
+ ])
mc = monorailcontext.MonorailContext(
self.services, cnxn=self.cnxn, requester='owner@example.com')
mc.LookupLoggedInUserPerms(self.project)
@@ -1176,10 +1198,11 @@
)
request.issue_ref.project_name = 'proj'
request.issue_ref.local_id = 1
- request.uploads.extend([
- issue_objects_pb2.AttachmentUpload(
- filename='a.txt',
- content='aaaaa')])
+ request.uploads.extend(
+ [
+ issue_objects_pb2.AttachmentUpload(
+ filename='a.txt', content=b'aaaaa')
+ ])
request.kept_attachments.extend([1, 2, 3])
request.send_email = True
@@ -1222,7 +1245,7 @@
work_env.WorkEnv(mc, self.services).UpdateIssueApproval.\
assert_called_once_with(
self.issue_1.issue_id, 3, ANY, u'Well, actually', False,
- attachments=[(u'a.txt', 'aaaaa', 'text/plain')], send_email=True,
+ attachments=[(u'a.txt', b'aaaaa', 'text/plain')], send_email=True,
kept_attachments=[1, 2, 3])
self.assertEqual(expected, actual)
@@ -1511,10 +1534,10 @@
response = self.CallWrapped(self.issues_svcr.IssueSnapshot, mc, request)
self.assertEqual(2, len(response.snapshot_count))
- self.assertEqual('Opened', response.snapshot_count[0].dimension)
- self.assertEqual(100, response.snapshot_count[0].count)
- self.assertEqual('Closed', response.snapshot_count[1].dimension)
- self.assertEqual(23, response.snapshot_count[1].count)
+ self.assertEqual('Closed', response.snapshot_count[0].dimension)
+ self.assertEqual(23, response.snapshot_count[0].count)
+ self.assertEqual('Opened', response.snapshot_count[1].dimension)
+ self.assertEqual(100, response.snapshot_count[1].count)
mockSnapshotCountsQuery.assert_called_once_with(self.project, 1531334109,
'open', label_prefix='', query=None, canned_query=None, hotlist=None)
@@ -1531,10 +1554,10 @@
response = self.CallWrapped(self.issues_svcr.IssueSnapshot, mc, request)
self.assertEqual(2, len(response.snapshot_count))
- self.assertEqual('Fixed', response.snapshot_count[0].dimension)
- self.assertEqual(23, response.snapshot_count[0].count)
- self.assertEqual('Accepted', response.snapshot_count[1].dimension)
- self.assertEqual(100, response.snapshot_count[1].count)
+ self.assertEqual('Accepted', response.snapshot_count[0].dimension)
+ self.assertEqual(100, response.snapshot_count[0].count)
+ self.assertEqual('Fixed', response.snapshot_count[1].dimension)
+ self.assertEqual(23, response.snapshot_count[1].count)
mockSnapshotCountsQuery.assert_called_once_with(self.project, 1531334109,
'status', label_prefix='', query=None, canned_query=None, hotlist=None)