Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/services/test/config_svc_test.py b/services/test/config_svc_test.py
index dd2796c..4100d3e 100644
--- a/services/test/config_svc_test.py
+++ b/services/test/config_svc_test.py
@@ -1,17 +1,17 @@
-# Copyright 2016 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 2016 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 config_svc module."""
 from __future__ import print_function
 from __future__ import division
 from __future__ import absolute_import
 
-import re
-import unittest
 import logging
 import mock
+import re
+import six
+import unittest
 
 try:
   from mox3 import mox
@@ -24,7 +24,7 @@
 from framework import exceptions
 from framework import framework_constants
 from framework import sql
-from proto import tracker_pb2
+from mrproto import tracker_pb2
 from services import config_svc
 from services import template_svc
 from testing import fake
@@ -220,7 +220,7 @@
         self.componentdef_rows, self.component2admin_rows,
         self.component2cc_rows, self.component2label_rows,
         self.approvaldef2approver_rows, self.approvaldef2survey_rows)
-    self.assertItemsEqual([789], list(config_dict.keys()))
+    six.assertCountEqual(self, [789], list(config_dict.keys()))
     config = config_dict[789]
     self.assertEqual(789, config.project_id)
     self.assertEqual(['Duplicate'], config.statuses_offer_merge)
@@ -280,7 +280,7 @@
     self.mox.ReplayAll()
     config_dict = self.config_2lc._FetchConfigs(self.cnxn, keys)
     self.mox.VerifyAll()
-    self.assertItemsEqual(keys, list(config_dict.keys()))
+    six.assertCountEqual(self, keys, list(config_dict.keys()))
 
   def testFetchItems(self):
     keys = [678, 789]
@@ -288,7 +288,7 @@
     self.mox.ReplayAll()
     config_dict = self.config_2lc.FetchItems(self.cnxn, keys)
     self.mox.VerifyAll()
-    self.assertItemsEqual(keys, list(config_dict.keys()))
+    six.assertCountEqual(self, keys, list(config_dict.keys()))
 
 
 class ConfigServiceTest(unittest.TestCase):
@@ -441,6 +441,22 @@
         self.cnxn, 789, 'NewLabel', autocreate=False))
     self.mox.VerifyAll()
 
+  def testLookupLabelID_CaseSensitive(self):
+    label_dicts = {101: 'security', 201: 'ux'}, {'security': 101, 'ux': 201}
+    self.config_service.label_cache.CacheItem(789, label_dicts)
+
+    self.config_service.labeldef_tbl.Select(
+        self.cnxn,
+        cols=['id'],
+        project_id=789,
+        where=[('label = %s', ['Security'])],
+        limit=1).AndReturn([])
+    self.mox.ReplayAll()
+    self.assertIsNone(
+        self.config_service.LookupLabelID(
+            self.cnxn, 789, 'Security', autocreate=False, case_sensitive=True))
+    self.mox.VerifyAll()
+
   def testLookupLabelIDs_Hit(self):
     label_dicts = {1: 'Security', 2: 'UX'}, {'security': 1, 'ux': 2}
     self.config_service.label_cache.CacheItem(789, label_dicts)
@@ -456,16 +472,16 @@
     self.config_service.label_cache.CacheItem(789, label_dicts)
     # No mock calls set up because none are needed.
     self.mox.ReplayAll()
-    self.assertItemsEqual(
-        [1],
+    six.assertCountEqual(
+        self, [1],
         self.config_service.LookupIDsOfLabelsMatching(
             self.cnxn, 789, re.compile('Sec.*')))
-    self.assertItemsEqual(
-        [1, 2],
+    six.assertCountEqual(
+        self, [1, 2],
         self.config_service.LookupIDsOfLabelsMatching(
             self.cnxn, 789, re.compile('.*')))
-    self.assertItemsEqual(
-        [],
+    six.assertCountEqual(
+        self, [],
         self.config_service.LookupIDsOfLabelsMatching(
             self.cnxn, 789, re.compile('Zzzzz.*')))
     self.mox.VerifyAll()
@@ -789,9 +805,7 @@
     with self.assertRaises(exceptions.InputException) as cm:
       self.config_service._UpdateWellKnownLabels(self.cnxn, config)
     self.mox.VerifyAll()
-    self.assertEqual(
-      'Defined label "Type-Defect" twice',
-      cm.exception.message)
+    self.assertEqual('Defined label "Type-Defect" twice', str(cm.exception))
 
   def testUpdateWellKnownStatuses(self):
     config = tracker_bizobj.MakeDefaultProjectIssueConfig(789)
@@ -1001,7 +1015,7 @@
     comp_ids = self.config_service.FindMatchingComponentIDsAnyProject(
         self.cnxn, ['WindowManager', 'NetworkLayer'])
     self.mox.VerifyAll()
-    self.assertItemsEqual([1, 2, 3], comp_ids)
+    six.assertCountEqual(self, [1, 2, 3], comp_ids)
 
   def testFindMatchingComponentIDsAnyProject_NonRooted(self):
     self.SetUpFindMatchingComponentIDsAnyProject(False, [(1,), (2,), (3,)])
@@ -1010,7 +1024,7 @@
     comp_ids = self.config_service.FindMatchingComponentIDsAnyProject(
         self.cnxn, ['WindowManager', 'NetworkLayer'], exact=False)
     self.mox.VerifyAll()
-    self.assertItemsEqual([1, 2, 3], comp_ids)
+    six.assertCountEqual(self, [1, 2, 3], comp_ids)
 
   def SetUpCreateComponentDef(self, comp_id):
     self.config_service.componentdef_tbl.InsertRow(