| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import webapp2 | 5 import webapp2 |
| 6 | 6 |
| 7 from testing_utils import testing | 7 from testing_utils import testing |
| 8 | 8 |
| 9 from handlers import swarming_task | 9 from handlers import swarming_task |
| 10 from waterfall import buildbot | 10 from waterfall import buildbot |
| 11 from waterfall import waterfall_config |
| 11 | 12 |
| 12 class SwarmingTaskTest(testing.AppengineTestCase): | 13 class SwarmingTaskTest(testing.AppengineTestCase): |
| 13 app_module = webapp2.WSGIApplication([ | 14 app_module = webapp2.WSGIApplication([ |
| 14 ('/swarming-task', swarming_task.SwarmingTask),], debug=True) | 15 ('/swarming-task', swarming_task.SwarmingTask),], debug=True) |
| 15 | 16 |
| 16 def setUp(self): | 17 def setUp(self): |
| 17 super(SwarmingTaskTest, self).setUp() | 18 super(SwarmingTaskTest, self).setUp() |
| 18 self.master_name = 'm' | 19 self.master_name = 'm' |
| 19 self.builder_name = 'b' | 20 self.builder_name = 'b' |
| 20 self.build_number = 121 | 21 self.build_number = 121 |
| 21 | 22 |
| 23 def MockedGetSwarmingSettings(): |
| 24 return {'server_host': 'chromium-swarm.appspot.com'} |
| 25 self.mock( |
| 26 waterfall_config, 'GetSwarmingSettings', MockedGetSwarmingSettings) |
| 27 |
| 22 def testSwarmingTaskHandler(self): | 28 def testSwarmingTaskHandler(self): |
| 23 build_url = buildbot.CreateBuildUrl( | 29 build_url = buildbot.CreateBuildUrl( |
| 24 self.master_name, self.builder_name, self.build_number) | 30 self.master_name, self.builder_name, self.build_number) |
| 25 response = self.test_app.get('/swarming-task', params={'url': build_url}) | 31 response = self.test_app.get('/swarming-task', params={'url': build_url}) |
| 26 expected_results = {} | 32 expected_results = {} |
| 27 | 33 |
| 28 self.assertEqual(200, response.status_int) | 34 self.assertEqual(200, response.status_int) |
| 29 self.assertEqual(expected_results, response.json_body) | 35 self.assertEqual(expected_results, response.json_body) |
| OLD | NEW |