Merge branch 'main' into avm99963-monorail

Merged commit 3779da353b36d43cf778e7d4f468097714dd4540

GitOrigin-RevId: 6451a5c6b75afb0fd1f37b3f14521148d0722ea8
diff --git a/framework/test/banned_test.py b/framework/test/banned_test.py
index 73b9f03..0331cdd 100644
--- a/framework/test/banned_test.py
+++ b/framework/test/banned_test.py
@@ -24,16 +24,16 @@
     self.services = service_manager.Services()
 
   def testAssertBasePermission(self):
-    servlet = banned.Banned('request', 'response', services=self.services)
+    servlet = banned.Banned(services=self.services)
 
     mr = monorailrequest.MonorailRequest(self.services)
     mr.auth.user_id = 0  # Anon user cannot see banned page.
-    with self.assertRaises(webapp2.HTTPException) as cm:
+    with self.assertRaises(Exception) as cm:
       servlet.AssertBasePermission(mr)
     self.assertEqual(404, cm.exception.code)
 
     mr.auth.user_id = 111  # User who is not banned cannot view banned page.
-    with self.assertRaises(webapp2.HTTPException) as cm:
+    with self.assertRaises(Exception) as cm:
       servlet.AssertBasePermission(mr)
     self.assertEqual(404, cm.exception.code)
 
@@ -42,7 +42,7 @@
     servlet.AssertBasePermission(mr)
 
   def testGatherPageData(self):
-    servlet = banned.Banned('request', 'response', services=self.services)
+    servlet = banned.Banned(services=self.services)
     self.assertNotEqual(servlet.template, None)
 
     _request, mr = testing_helpers.GetRequestObjects()
diff --git a/framework/test/deleteusers_test.py b/framework/test/deleteusers_test.py
index 2609867..87ed5bc 100644
--- a/framework/test/deleteusers_test.py
+++ b/framework/test/deleteusers_test.py
@@ -25,8 +25,7 @@
 
   def setUp(self):
     self.services = service_manager.Services(user=fake.UserService())
-    self.task = deleteusers.WipeoutSyncCron(
-        request=None, response=None, services=self.services)
+    self.task = deleteusers.WipeoutSyncCron(services=self.services)
     self.user_1 = self.services.user.TestAddUser('user1@example.com', 111)
     self.user_2 = self.services.user.TestAddUser('user2@example.com', 222)
     self.user_3 = self.services.user.TestAddUser('user3@example.com', 333)
@@ -100,8 +99,7 @@
 
   def setUp(self):
     self.services = service_manager.Services(user=fake.UserService())
-    self.task = deleteusers.SendWipeoutUserListsTask(
-        request=None, response=None, services=self.services)
+    self.task = deleteusers.SendWipeoutUserListsTask(services=self.services)
     self.task.sendUserLists = mock.Mock()
     deleteusers.authorize = mock.Mock(return_value='service')
     self.user_1 = self.services.user.TestAddUser('user1@example.com', 111)
@@ -143,8 +141,7 @@
   def setUp(self):
     self.services = service_manager.Services()
     deleteusers.authorize = mock.Mock(return_value='service')
-    self.task = deleteusers.DeleteWipeoutUsersTask(
-        request=None, response=None, services=self.services)
+    self.task = deleteusers.DeleteWipeoutUsersTask(services=self.services)
     deleted_users = [
         {'id': 'user1@gmail.com'}, {'id': 'user2@gmail.com'},
         {'id': 'user3@gmail.com'}, {'id': 'user4@gmail.com'}]
diff --git a/framework/test/framework_helpers_test.py b/framework/test/framework_helpers_test.py
index 1d0146c..fb8810b 100644
--- a/framework/test/framework_helpers_test.py
+++ b/framework/test/framework_helpers_test.py
@@ -11,7 +11,10 @@
 import mock
 import unittest
 
-import mox
+try:
+  from mox3 import mox
+except ImportError:
+  import mox
 import time
 
 from businesslogic import work_env
diff --git a/framework/test/monorailcontext_test.py b/framework/test/monorailcontext_test.py
index ed93920..2071c9e 100644
--- a/framework/test/monorailcontext_test.py
+++ b/framework/test/monorailcontext_test.py
@@ -10,7 +10,10 @@
 
 import unittest
 
-import mox
+try:
+  from mox3 import mox
+except ImportError:
+  import mox
 
 from framework import authdata
 from framework import monorailcontext
diff --git a/framework/test/monorailrequest_test.py b/framework/test/monorailrequest_test.py
index fcd30c3..ef52f1e 100644
--- a/framework/test/monorailrequest_test.py
+++ b/framework/test/monorailrequest_test.py
@@ -13,7 +13,10 @@
 import re
 import unittest
 
-import mox
+try:
+  from mox3 import mox
+except ImportError:
+  import mox
 import six
 
 from google.appengine.api import oauth
diff --git a/framework/test/permissions_test.py b/framework/test/permissions_test.py
index 0917b53..cd67c6c 100644
--- a/framework/test/permissions_test.py
+++ b/framework/test/permissions_test.py
@@ -11,7 +11,10 @@
 import time
 import unittest
 
-import mox
+try:
+  from mox3 import mox
+except ImportError:
+  import mox
 
 import settings
 from framework import authdata
diff --git a/framework/test/ratelimiter_test.py b/framework/test/ratelimiter_test.py
index b351f8c..84230e8 100644
--- a/framework/test/ratelimiter_test.py
+++ b/framework/test/ratelimiter_test.py
@@ -15,7 +15,10 @@
 from google.appengine.api import memcache
 from google.appengine.ext import testbed
 
-import mox
+try:
+  from mox3 import mox
+except ImportError:
+  import mox
 import os
 import settings
 
diff --git a/framework/test/reap_test.py b/framework/test/reap_test.py
index f1a907d..92d17fb 100644
--- a/framework/test/reap_test.py
+++ b/framework/test/reap_test.py
@@ -11,7 +11,10 @@
 import unittest
 
 import mock
-import mox
+try:
+  from mox3 import mox
+except ImportError:
+  import mox
 
 from mock import Mock
 
@@ -69,7 +72,7 @@
 
   def testMarkDoomedProjects(self):
     self.setUpMarkDoomedProjects()
-    reaper = reap.Reap('req', 'resp', services=self.services)
+    reaper = reap.Reap(services=self.services)
 
     self.mox.ReplayAll()
     doomed_project_ids = reaper._MarkDoomedProjects(self.cnxn)
@@ -92,7 +95,7 @@
 
   def testExpungeDeletableProjects(self):
     self.setUpExpungeParts()
-    reaper = reap.Reap('req', 'resp', services=self.services)
+    reaper = reap.Reap(services=self.services)
 
     self.mox.ReplayAll()
     expunged_project_ids = reaper._ExpungeDeletableProjects(self.cnxn)
diff --git a/framework/test/sorting_test.py b/framework/test/sorting_test.py
index 4b1feb3..4251308 100644
--- a/framework/test/sorting_test.py
+++ b/framework/test/sorting_test.py
@@ -12,7 +12,10 @@
 # For convenient debugging
 import logging
 
-import mox
+try:
+  from mox3 import mox
+except ImportError:
+  import mox
 
 from framework import sorting
 from framework import framework_views
diff --git a/framework/test/warmup_test.py b/framework/test/warmup_test.py
index 8140fc7..13223f1 100644
--- a/framework/test/warmup_test.py
+++ b/framework/test/warmup_test.py
@@ -10,26 +10,39 @@
 
 import unittest
 
-from testing import testing_helpers
+import flask
 
-from framework import sql
 from framework import warmup
-from services import service_manager
 
 
 class WarmupTest(unittest.TestCase):
 
-  def setUp(self):
-    #self.cache_manager = cachemanager_svc.CacheManager()
-    #self.services = service_manager.Services(
-    #    cache_manager=self.cache_manager)
-    self.services = service_manager.Services()
-    self.servlet = warmup.Warmup('req', 'res', services=self.services)
+  def testHandleWarmup(self):
+    app = flask.Flask(__name__)
+    app.add_url_rule('/', view_func=warmup.Warmup)
 
+    with app.test_client() as client:
+      response = client.get('/')
 
-  def testHandleRequest_NothingToDo(self):
-    mr = testing_helpers.MakeMonorailRequest()
-    actual_json_data = self.servlet.HandleRequest(mr)
-    self.assertEqual(
-        {'success': 1},
-        actual_json_data)
+    self.assertEqual(response.status_code, 200)
+    self.assertEqual(response.data, '')
+
+  def testHandleStart(self):
+    app = flask.Flask(__name__)
+    app.add_url_rule('/', view_func=warmup.Start)
+
+    with app.test_client() as client:
+      response = client.get('/')
+
+    self.assertEqual(response.status_code, 200)
+    self.assertEqual(response.data, '')
+
+  def testHandleStop(self):
+    app = flask.Flask(__name__)
+    app.add_url_rule('/', view_func=warmup.Stop)
+
+    with app.test_client() as client:
+      response = client.get('/')
+
+    self.assertEqual(response.status_code, 200)
+    self.assertEqual(response.data, '')