Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/services/test/user_svc_test.py b/services/test/user_svc_test.py
index 323d3eb..c709d75 100644
--- a/services/test/user_svc_test.py
+++ b/services/test/user_svc_test.py
@@ -1,13 +1,13 @@
-# 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.
 
 """Tests for the user service."""
 from __future__ import print_function
 from __future__ import division
 from __future__ import absolute_import
 
+import six
 import unittest
 
 import mock
@@ -22,7 +22,7 @@
 from framework import exceptions
 from framework import framework_constants
 from framework import sql
-from proto import user_pb2
+from mrproto import user_pb2
 from services import user_svc
 from testing import fake
 
@@ -126,16 +126,17 @@
     self.mox.UnsetStubs()
     self.mox.ResetAll()
 
-  def SetUpCreateUsers(self):
+  def testCreateUsers(self):
+    self.user_service.user_tbl.Select(
+        self.cnxn,
+        cols=('user_id',),
+        user_id=[3035911623, 2996997680],
+    ).AndReturn([(2996997680,)])
     self.user_service.user_tbl.InsertRows(
         self.cnxn,
         ['user_id', 'email', 'obscure_email'],
-        [(3035911623, 'a@example.com', True),
-         (2996997680, 'b@example.com', True)]
+        [(3035911623, 'a@example.com', True)],
     ).AndReturn(None)
-
-  def testCreateUsers(self):
-    self.SetUpCreateUsers()
     self.mox.ReplayAll()
     self.user_service._CreateUsers(
         self.cnxn, ['a@example.com', 'b@example.com'])
@@ -461,7 +462,7 @@
     self.user_service.linkedaccount_tbl.Select.return_value = []
     with self.assertRaises(exceptions.InputException) as cm:
       self.user_service.AcceptLinkedChild(self.cnxn, 111, 333)
-    self.assertEqual('No such invite', cm.exception.message)
+    self.assertEqual('No such invite', str(cm.exception))
 
   def testAcceptLinkedChild_Normal(self):
     """Create linkage between accounts and remove invite."""
@@ -587,8 +588,8 @@
         self.cnxn, cols=['email'], limit=1000, offset=0,
         where=[('user_id != %s', [framework_constants.DELETED_USER_ID])],
         order_by=[('user_id ASC', [])])
-    self.assertItemsEqual(
-        emails, ['cow@test.com', 'pig@test.com', 'fox@test.com'])
+    six.assertCountEqual(
+        self, emails, ['cow@test.com', 'pig@test.com', 'fox@test.com'])
 
   def testGetAllUserEmailsBatch_CustomLimit(self):
     rows = [('cow@test.com',), ('pig@test.com',), ('fox@test.com',)]
@@ -599,5 +600,5 @@
         self.cnxn, cols=['email'], limit=30, offset=60,
         where=[('user_id != %s', [framework_constants.DELETED_USER_ID])],
         order_by=[('user_id ASC', [])])
-    self.assertItemsEqual(
-        emails, ['cow@test.com', 'pig@test.com', 'fox@test.com'])
+    six.assertCountEqual(
+        self, emails, ['cow@test.com', 'pig@test.com', 'fox@test.com'])