Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/features/test/notify_test.py b/features/test/notify_test.py
index e73488d..e4f00a3 100644
--- a/features/test/notify_test.py
+++ b/features/test/notify_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.
 
 """Tests for notify.py."""
 from __future__ import print_function
 from __future__ import division
 from __future__ import absolute_import
 
+import flask
 import json
 import mock
+import six
 import unittest
-import flask
 
 from google.appengine.ext import testbed
 
@@ -19,7 +19,7 @@
 from features import notify_reasons
 from framework import emailfmt
 from framework import urls
-from proto import tracker_pb2
+from mrproto import tracker_pb2
 from services import service_manager
 from testing import fake
 from testing import testing_helpers
@@ -131,7 +131,7 @@
     task = notify.NotifyBlockingChangeTask(services=self.services)
     params = {
         'send_email': 1, 'issue_id': issue2.issue_id, 'seq': 0,
-        'delta_blocker_iids': self.issue1.issue_id, 'commenter_id': 1,
+        'delta_blocker_iids': str(self.issue1.issue_id), 'commenter_id': 1,
         'hostport': 'bugs.chromium.org'}
     mr = testing_helpers.MakeMonorailRequest(
         user_info={'user_id': 1},
@@ -149,7 +149,7 @@
     task = notify.NotifyBlockingChangeTask(services=self.services)
     params = {
         'send_email': 1, 'issue_id': issue2.issue_id, 'seq': 0,
-        'delta_blocker_iids': self.issue1.issue_id, 'commenter_id': 1}
+        'delta_blocker_iids': str(self.issue1.issue_id), 'commenter_id': 1}
     mr = testing_helpers.MakeMonorailRequest(
         user_info={'user_id': 1},
         params=params,
@@ -213,7 +213,8 @@
         create_task_mock, urls.OUTBOUND_EMAIL_TASK + '.do')
     self.assertEqual(3, len(call_args_list))
 
-    self.assertItemsEqual(
+    six.assertCountEqual(
+        self,
         ['user@example.com', 'mailing-list@example.com', 'member@example.com'],
         result['notified'])
     for (args, _kwargs) in call_args_list:
@@ -247,8 +248,8 @@
         create_task_mock, urls.OUTBOUND_EMAIL_TASK + '.do')
     self.assertEqual(2, len(call_args_list))
 
-    self.assertItemsEqual(
-        ['user@example.com', 'mailing-list@example.com'],
+    six.assertCountEqual(
+        self, ['user@example.com', 'mailing-list@example.com'],
         result['notified'])
 
     for (args, _kwargs) in call_args_list:
@@ -532,12 +533,13 @@
     self.assertTrue('sploot.jpg' in result['tasks'][0]['body'])
     self.assertTrue(
         '/issues/attachment?aid=4567' in result['tasks'][0]['body'])
-    self.assertItemsEqual(
-        ['user@example.com', 'approver_old@example.com',
-         'approver_new@example.com', 'TL@example.com',
-         'approvalTL@example.com', 'group_mem1@example.com',
-         'group_mem2@example.com', 'group_mem3@example.com'],
-        result['notified'])
+    six.assertCountEqual(
+        self, [
+            'user@example.com', 'approver_old@example.com',
+            'approver_new@example.com', 'TL@example.com',
+            'approvalTL@example.com', 'group_mem1@example.com',
+            'group_mem2@example.com', 'group_mem3@example.com'
+        ], result['notified'])
 
     # Test no approvers/groups notified
     # Status change to NEED_INFO does not email approvers.
@@ -564,8 +566,8 @@
     self.assertIsNotNone(result['tasks'][0].get('references'))
     self.assertEqual(result['tasks'][0]['reply_to'], emailfmt.NoReplyAddress())
     self.assertTrue('Status: need_info' in result['tasks'][0]['body'])
-    self.assertItemsEqual(
-        ['user@example.com', 'TL@example.com', 'approvalTL@example.com'],
+    six.assertCountEqual(
+        self, ['user@example.com', 'TL@example.com', 'approvalTL@example.com'],
         result['notified'])
 
   def testNotifyApprovalChangeTask_GetApprovalEmailRecipients(self):
@@ -580,7 +582,7 @@
     # Comment with not amendments notifies everyone.
     rids = task._GetApprovalEmailRecipients(
         approval_value, comment, issue, [777, 888])
-    self.assertItemsEqual(rids, [111, 222, 333, 777, 888])
+    six.assertCountEqual(self, rids, [111, 222, 333, 777, 888])
 
     # New APPROVED status notifies owners and any_comment users.
     amendment = tracker_bizobj.MakeApprovalStatusAmendment(
@@ -588,7 +590,7 @@
     comment.amendments = [amendment]
     rids = task._GetApprovalEmailRecipients(
         approval_value, comment, issue, [777, 888])
-    self.assertItemsEqual(rids, [111, 777, 888])
+    six.assertCountEqual(self, rids, [111, 777, 888])
 
     # New REVIEW_REQUESTED status notifies approvers.
     approval_value.status = tracker_pb2.ApprovalStatus.REVIEW_REQUESTED
@@ -597,7 +599,7 @@
     comment.amendments = [amendment]
     rids = task._GetApprovalEmailRecipients(
         approval_value, comment, issue, [777, 888])
-    self.assertItemsEqual(rids, [222, 333])
+    six.assertCountEqual(self, rids, [222, 333])
 
     # Approvers change notifies everyone.
     amendment = tracker_bizobj.MakeApprovalApproversAmendment(
@@ -606,7 +608,7 @@
     approval_value.approver_ids = [222]
     rids = task._GetApprovalEmailRecipients(
         approval_value, comment, issue, [777], omit_ids=[444, 333])
-    self.assertItemsEqual(rids, [111, 222, 555, 777])
+    six.assertCountEqual(self, rids, [111, 222, 555, 777])
 
   @mock.patch('framework.cloud_tasks_helpers.create_task')
   def testNotifyRulesDeletedTask(self, _create_task_mock):
@@ -627,8 +629,8 @@
     self.assertTrue('if green make yellow' in body)
     self.assertTrue('if green make yellow' in body)
     self.assertTrue('/p/proj/adminRules' in body)
-    self.assertItemsEqual(
-        ['cow@test.com', 'owner1@test.com'], result['notified'])
+    six.assertCountEqual(
+        self, ['cow@test.com', 'owner1@test.com'], result['notified'])
 
   def testOutboundEmailTask_Normal(self):
     """We can send an email."""
@@ -656,7 +658,7 @@
     res_json = json.loads(res_string)
     self.assertEqual(
         'Skipping because no "to" address found.', res_json['note'])
-    self.assertNotIn('from_addr', res_string)
+    self.assertNotIn(b'from_addr', res_string)
 
   def testOutboundEmailTask_BannedUser(self):
     """We don't send emails to banned users.."""
@@ -672,4 +674,4 @@
     res_string = res.get_data()[5:]
     res_json = json.loads(res_string)
     self.assertEqual('Skipping because user is banned.', res_json['note'])
-    self.assertNotIn('from_addr', res_string)
+    self.assertNotIn(b'from_addr', res_string)