Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/tracker/test/templatedetail_test.py b/tracker/test/templatedetail_test.py
index 42fc46b..3968554 100644
--- a/tracker/test/templatedetail_test.py
+++ b/tracker/test/templatedetail_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.
 
 """Unit tests for Template editing/viewing servlet."""
 from __future__ import print_function
@@ -13,6 +12,7 @@
 except ImportError:
   import mox
 import logging
+import six
 import unittest
 import settings
 
@@ -27,7 +27,7 @@
 from testing import testing_helpers
 from tracker import templatedetail
 from tracker import tracker_bizobj
-from proto import tracker_pb2
+from mrproto import tracker_pb2
 
 
 class TemplateDetailTest(unittest.TestCase):
@@ -41,8 +41,7 @@
                                              template=mock_template_service,
                                              usergroup=fake.UserGroupService(),
                                              user=fake.UserService())
-    self.servlet = templatedetail.TemplateDetail('req', 'res',
-                                               services=self.services)
+    self.servlet = templatedetail.TemplateDetail(services=self.services)
 
     self.services.user.TestAddUser('gatsby@example.com', 111)
     self.services.user.TestAddUser('sport@example.com', 222)
@@ -271,8 +270,8 @@
     self.assertTrue(page_data['initial_owner_defaults_to_member'])
     self.assertEqual(page_data['initial_components'], 'BackEnd')
     self.assertFalse(page_data['initial_component_required'])
-    self.assertItemsEqual(
-        page_data['labels'],
+    six.assertCountEqual(
+        self, page_data['labels'],
         ['label1', 'label2', 'GateTarget-Should-Not', 'GateTarget-Be-Masked'])
     self.assertEqual(page_data['initial_admins'], 'sport@example.com')
     self.assertTrue(page_data['initial_add_approvals'])
@@ -280,8 +279,8 @@
     phases = [phase for phase in page_data['initial_phases'] if phase.name]
     self.assertEqual(len(phases), 2)
     self.assertEqual(len(page_data['approvals']), 2)
-    self.assertItemsEqual(page_data['prechecked_approvals'],
-                          ['3_phase_0', '4_phase_1'])
+    six.assertCountEqual(
+        self, page_data['prechecked_approvals'], ['3_phase_0', '4_phase_1'])
     self.assertTrue(page_data['fields'][3].is_editable)  #nonRestrictedField
     self.assertIsNone(page_data['fields'][4].is_editable)  #restrictedField
 
@@ -439,7 +438,7 @@
 
     self.services.template.UpdateIssueTemplateDef.assert_called_once_with(
         self.mr.cnxn,
-        47925,
+        self.mr.project_id,
         12345,
         status='Accepted',
         component_required=True,
@@ -496,19 +495,32 @@
     self.assertTrue('/templates/detail?saved=1&template=TestTemplate&' in url)
 
     self.services.template.UpdateIssueTemplateDef.assert_called_once_with(
-        self.mr.cnxn, 47925, 12345, status='Accepted', component_required=True,
+        self.mr.cnxn,
+        self.mr.project_id,
+        12345,
+        status='Accepted',
+        component_required=True,
         phases=[
             tracker_pb2.Phase(name='Canary', rank=0, phase_id=0),
-            tracker_pb2.Phase(name='Stable', rank=1, phase_id=1)],
-        approval_values=[tracker_pb2.ApprovalValue(approval_id=3, phase_id=0),
-                         tracker_pb2.ApprovalValue(approval_id=4, phase_id=1)],
-        name='TestTemplate', field_values=[
+            tracker_pb2.Phase(name='Stable', rank=1, phase_id=1)
+        ],
+        approval_values=[
+            tracker_pb2.ApprovalValue(approval_id=3, phase_id=0),
+            tracker_pb2.ApprovalValue(approval_id=4, phase_id=1)
+        ],
+        name='TestTemplate',
+        field_values=[
             tracker_pb2.FieldValue(field_id=1, str_value='NO', derived=False),
-            tracker_pb2.FieldValue(
-                field_id=2, str_value='MOOD', derived=False)],
-        labels=['label-One', 'label-Two'], owner_defaults_to_member=True,
-        admin_ids=[], content='HEY WHY', component_ids=[1],
-        summary_must_be_edited=False, summary='TLDR', members_only=True,
+            tracker_pb2.FieldValue(field_id=2, str_value='MOOD', derived=False)
+        ],
+        labels=['label-One', 'label-Two'],
+        owner_defaults_to_member=True,
+        admin_ids=[],
+        content='HEY WHY',
+        component_ids=[1],
+        summary_must_be_edited=False,
+        summary='TLDR',
+        members_only=True,
         owner_id=333)
 
   def testProcessFormData_Delete(self):
@@ -521,4 +533,4 @@
 
     self.assertTrue('/p/None/adminTemplates?deleted=1' in url)
     self.services.template.DeleteIssueTemplateDef\
-        .assert_called_once_with(self.mr.cnxn, 47925, 12345)
+        .assert_called_once_with(self.mr.cnxn, self.mr.project_id, 12345)