Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: appengine/swarming/handlers_test.py

Issue 2832243002: swarming: mechanical changes to unit tests (Closed)
Patch Set: Disable tx before calling tq Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 # Copyright 2013 The LUCI Authors. All rights reserved. 3 # Copyright 2013 The LUCI Authors. All rights reserved.
4 # Use of this source code is governed under the Apache License, Version 2.0 4 # Use of this source code is governed under the Apache License, Version 2.0
5 # that can be found in the LICENSE file. 5 # that can be found in the LICENSE file.
6 6
7 import datetime 7 import datetime
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
11 import sys 11 import sys
12 import unittest 12 import unittest
13 import urllib 13 import urllib
14 14
15 # Setups environment. 15 # Setups environment.
16 import test_env_handlers 16 import test_env_handlers
17 17
18 import webtest 18 import webtest
19 19
20 import handlers_backend 20 import handlers_backend
21 import handlers_frontend 21 import handlers_frontend
22 import template 22 import template
23 from components import utils
23 from server import bot_code 24 from server import bot_code
24 from server import bot_management 25 from server import bot_management
25 from server import task_result 26 from server import task_result
26 27
27 28
28 class AppTestBase(test_env_handlers.AppTestBase): 29 class AppTestBase(test_env_handlers.AppTestBase):
29 @staticmethod 30 @staticmethod
30 def wsgi_app(): 31 def wsgi_app():
31 return None 32 return None
32 33
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 @staticmethod 242 @staticmethod
242 def wsgi_app(): 243 def wsgi_app():
243 return handlers_backend.create_application(True) 244 return handlers_backend.create_application(True)
244 245
245 def _GetRoutes(self): 246 def _GetRoutes(self):
246 """Returns the list of all routes handled.""" 247 """Returns the list of all routes handled."""
247 return [ 248 return [
248 r.template for r in self.app.app.router.match_routes 249 r.template for r in self.app.app.router.match_routes
249 ] 250 ]
250 251
252 def setUp(self):
253 super(BackendTest, self).setUp()
254 self._enqueue_task_orig = self.mock(
255 utils, 'enqueue_task', self._enqueue_task)
256
257 def _enqueue_task(self, **kwargs):
258 return self._enqueue_task_orig(use_dedicated_module=False, **kwargs)
259
251 def testCronJobTasks(self): 260 def testCronJobTasks(self):
252 # Tests all the cron tasks are securely handled. 261 # Tests all the cron tasks are securely handled.
253 cron_job_urls = [ 262 cron_job_urls = [
254 r for r in self._GetRoutes() if r.startswith('/internal/cron/') 263 r for r in self._GetRoutes() if r.startswith('/internal/cron/')
255 ] 264 ]
256 self.assertTrue(cron_job_urls, cron_job_urls) 265 self.assertTrue(cron_job_urls, cron_job_urls)
257 266
258 # For ereporter. 267 # For ereporter.
259 for cron_job_url in cron_job_urls: 268 for cron_job_url in cron_job_urls:
260 self.app.get( 269 self.app.get(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 url+arg, headers={'X-AppEngine-QueueName': 'bogus name'}, status=403) 359 url+arg, headers={'X-AppEngine-QueueName': 'bogus name'}, status=403)
351 360
352 361
353 if __name__ == '__main__': 362 if __name__ == '__main__':
354 if '-v' in sys.argv: 363 if '-v' in sys.argv:
355 unittest.TestCase.maxDiff = None 364 unittest.TestCase.maxDiff = None
356 logging.basicConfig( 365 logging.basicConfig(
357 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, 366 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL,
358 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') 367 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s')
359 unittest.main() 368 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_endpoints_test.py ('k') | appengine/swarming/server/task_scheduler_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698