Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/framework/test/deleteusers_test.py b/framework/test/deleteusers_test.py
index 87ed5bc..13c6922 100644
--- a/framework/test/deleteusers_test.py
+++ b/framework/test/deleteusers_test.py
@@ -1,7 +1,6 @@
-# Copyright 2019 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 2019 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 deleteusers classes."""
 from __future__ import print_function
@@ -10,6 +9,7 @@
 
 import logging
 import mock
+import six
 import unittest
 from six.moves import urllib
 
@@ -52,24 +52,24 @@
     self.assertEqual(get_client_mock().create_task.call_count, 3)
 
     expected_task = self.generate_simple_task(
-        urls.SEND_WIPEOUT_USER_LISTS_TASK + '.do', 'limit=2&offset=0')
+        urls.SEND_WIPEOUT_USER_LISTS_TASK + '.do', b'limit=2&offset=0')
     get_client_mock().create_task.assert_any_call(
-        get_client_mock().queue_path(),
-        expected_task,
+        parent=get_client_mock().queue_path(),
+        task=expected_task,
         retry=cloud_tasks_helpers._DEFAULT_RETRY)
 
     expected_task = self.generate_simple_task(
-        urls.SEND_WIPEOUT_USER_LISTS_TASK + '.do', 'limit=2&offset=2')
+        urls.SEND_WIPEOUT_USER_LISTS_TASK + '.do', b'limit=2&offset=2')
     get_client_mock().create_task.assert_any_call(
-        get_client_mock().queue_path(),
-        expected_task,
+        parent=get_client_mock().queue_path(),
+        task=expected_task,
         retry=cloud_tasks_helpers._DEFAULT_RETRY)
 
     expected_task = self.generate_simple_task(
-        urls.DELETE_WIPEOUT_USERS_TASK + '.do', '')
+        urls.DELETE_WIPEOUT_USERS_TASK + '.do', b'')
     get_client_mock().create_task.assert_any_call(
-        get_client_mock().queue_path(),
-        expected_task,
+        parent=get_client_mock().queue_path(),
+        task=expected_task,
         retry=cloud_tasks_helpers._DEFAULT_RETRY)
 
   @mock.patch('framework.cloud_tasks_helpers._get_client')
@@ -79,10 +79,10 @@
 
     expected_task = self.generate_simple_task(
         urls.SEND_WIPEOUT_USER_LISTS_TASK + '.do',
-        'limit={}&offset=0'.format(deleteusers.MAX_BATCH_SIZE))
+        b'limit=%d&offset=0' % deleteusers.MAX_BATCH_SIZE)
     get_client_mock().create_task.assert_any_call(
-        get_client_mock().queue_path(),
-        expected_task,
+        parent=get_client_mock().queue_path(),
+        task=expected_task,
         retry=cloud_tasks_helpers._DEFAULT_RETRY)
 
   @mock.patch('framework.cloud_tasks_helpers._get_client')
@@ -118,13 +118,13 @@
   def testHandleRequest_NoLimit(self):
     mr = testing_helpers.MakeMonorailRequest()
     self.services.user.users_by_id = {}
-    with self.assertRaisesRegexp(AssertionError, 'Missing param limit'):
+    with self.assertRaisesRegex(AssertionError, 'Missing param limit'):
       self.task.HandleRequest(mr)
 
   def testHandleRequest_NoOffset(self):
     mr = testing_helpers.MakeMonorailRequest(path='url/url?limit=3')
     self.services.user.users_by_id = {}
-    with self.assertRaisesRegexp(AssertionError, 'Missing param offset'):
+    with self.assertRaisesRegex(AssertionError, 'Missing param offset'):
       self.task.HandleRequest(mr)
 
   def testHandleRequest_ZeroOffset(self):
@@ -152,7 +152,7 @@
         'app_engine_http_request':
             {
                 'relative_uri': url,
-                'body': body,
+                'body': six.ensure_binary(body),
                 'headers': {
                     'Content-type': 'application/x-www-form-urlencoded'
                 }
@@ -178,8 +178,8 @@
         urls.DELETE_USERS_TASK + '.do', query)
 
     get_client_mock().create_task.assert_any_call(
-        get_client_mock().queue_path(),
-        expected_task,
+        parent=get_client_mock().queue_path(),
+        task=expected_task,
         retry=cloud_tasks_helpers._DEFAULT_RETRY)
 
     query = urllib.parse.urlencode({'emails': 'user4@gmail.com'})
@@ -187,8 +187,8 @@
         urls.DELETE_USERS_TASK + '.do', query)
 
     get_client_mock().create_task.assert_any_call(
-        get_client_mock().queue_path(),
-        expected_task,
+        parent=get_client_mock().queue_path(),
+        task=expected_task,
         retry=cloud_tasks_helpers._DEFAULT_RETRY)
 
   @mock.patch('framework.cloud_tasks_helpers._get_client')
@@ -206,6 +206,6 @@
         urls.DELETE_USERS_TASK + '.do', query)
 
     get_client_mock().create_task.assert_any_call(
-        get_client_mock().queue_path(),
-        expected_task,
+        parent=get_client_mock().queue_path(),
+        task=expected_task,
         retry=cloud_tasks_helpers._DEFAULT_RETRY)