Chromium Code Reviews| Index: appengine/findit/handlers/test/build_failure_test.py |
| diff --git a/appengine/findit/handlers/test/build_failure_test.py b/appengine/findit/handlers/test/build_failure_test.py |
| index 71399d30a60bafc00a27cc7750f31e7e1691aa28..5f37c1615c710e249b4272f9d0c9a420c6bd43c6 100644 |
| --- a/appengine/findit/handlers/test/build_failure_test.py |
| +++ b/appengine/findit/handlers/test/build_failure_test.py |
| @@ -6,24 +6,23 @@ import os |
| import re |
| from google.appengine.ext import testbed |
| + |
| import webapp2 |
| import webtest |
| -from testing_utils import testing |
| - |
| from handlers import build_failure |
| -from model.wf_analysis import WfAnalysis |
| from model import wf_analysis_status |
| +from model.wf_analysis import WfAnalysis |
| from waterfall import buildbot |
| -from waterfall import waterfall_config |
| - |
| +from waterfall.test import wf_configured_test_case |
| # Root directory appengine/findit. |
| ROOT_DIR = os.path.join(os.path.dirname(__file__), |
| os.path.pardir, os.path.pardir) |
| -class BuildFailureTest(testing.AppengineTestCase): |
| +class BuildFailureTest( |
| + wf_configured_test_case.WaterfallConfiguredTestCase): |
| app_module = webapp2.WSGIApplication([ |
| ('/build-failure', build_failure.BuildFailure), |
| ], debug=True) |
| @@ -74,17 +73,12 @@ class BuildFailureTest(testing.AppengineTestCase): |
| self.test_app.get, '/build-failure', params={'url': build_url}) |
| def testNonAdminCanViewAnalysisOfFailureOnUnsupportedMaster(self): |
| - master_name = 'm' |
| + master_name = 'm2' |
| builder_name = 'b 1' |
| build_number = 123 |
| build_url = buildbot.CreateBuildUrl( |
| master_name, builder_name, build_number) |
| - def MockMasterIsSupported(*_): |
| - return False |
| - self.mock(waterfall_config, 'MasterIsSupported', |
| - MockMasterIsSupported) |
| - |
| analysis = WfAnalysis.Create(master_name, builder_name, build_number) |
| analysis.status = wf_analysis_status.ANALYZED |
| analysis.put() |
| @@ -95,16 +89,12 @@ class BuildFailureTest(testing.AppengineTestCase): |
| self.assertEqual(0, len(self.taskqueue_stub.get_filtered_tasks())) |
| def testNonAdminCannotRequestAnalysisOfFailureOnUnsupportedMaster(self): |
| - master_name = 'm' |
| + master_name = 'm2' |
| builder_name = 'b 1' |
| build_number = 123 |
| build_url = buildbot.CreateBuildUrl( |
| master_name, builder_name, build_number) |
| - def MockMasterIsSupported(*_): |
| - return False |
| - self.mock(waterfall_config, 'MasterIsSupported', MockMasterIsSupported) |
| - |
| self.assertRaisesRegexp( |
| webtest.app.AppError, |
| re.compile('.*501 Not Implemented.*Master "%s" ' |
| @@ -113,16 +103,12 @@ class BuildFailureTest(testing.AppengineTestCase): |
| self.test_app.get, '/build-failure', params={'url': build_url}) |
| def testAdminCanRequestAnalysisOfFailureOnUnsupportedMaster(self): |
| - master_name = 'm' |
| + master_name = 'm2' |
| builder_name = 'b' |
| build_number = 123 |
| build_url = buildbot.CreateBuildUrl( |
| master_name, builder_name, build_number) |
| - def MockMasterIsSupported(*_): |
| - return False |
| - self.mock(waterfall_config, 'MasterIsSupported', MockMasterIsSupported) |
| - |
| self.mock_current_user(user_email='test@chromium.org', is_admin=True) |
| response = self.test_app.get('/build-failure', params={'url': build_url}) |
| @@ -137,9 +123,7 @@ class BuildFailureTest(testing.AppengineTestCase): |
| build_url = buildbot.CreateBuildUrl( |
| master_name, builder_name, build_number) |
| - def MockMasterIsSupported(*_): |
| - return True |
| - self.mock(waterfall_config, 'MasterIsSupported', MockMasterIsSupported) |
| + self.mock_current_user(user_email='anyone@chromium.org', is_admin=False) |
|
stgao
2016/03/31 18:07:13
Why we need this? By default, no user is mocked.
lijeffrey
2016/03/31 22:50:20
Done.
|
| response = self.test_app.get('/build-failure', params={'url': build_url}) |
| self.assertEquals(200, response.status_int) |