| OLD | NEW |
| (Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import mock |
| 6 import pickle |
| 7 import re |
| 8 |
| 9 from google.appengine.ext import testbed |
| 10 import webapp2 |
| 11 import webtest |
| 12 |
| 13 from testing_utils import testing |
| 14 |
| 15 from handlers import process_flake_analysis_request |
| 16 |
| 17 |
| 18 class ProcessFlakeAnalysisRequestsTest(testing.AppengineTestCase): |
| 19 app_module = webapp2.WSGIApplication([ |
| 20 ('/process-flake-analysis-request', |
| 21 process_flake_analysis_request.ProcessFlakeAnalysisRequest), |
| 22 ], debug=True) |
| 23 |
| 24 def testNonAdminCanNotSendRequest(self): |
| 25 self.assertRaisesRegexp( |
| 26 webtest.app.AppError, |
| 27 re.compile('.*401 Unauthorized.*' |
| 28 'Error: Either not login or no permission.*', |
| 29 re.MULTILINE | re.DOTALL), |
| 30 self.test_app.post, |
| 31 '/process-flake-analysis-request', |
| 32 params='') |
| 33 |
| 34 @mock.patch.object( |
| 35 process_flake_analysis_request.flake_analysis_service, |
| 36 'ScheduleAnalysisForFlake') |
| 37 def testAdminCanRequestAnalysis(self, mocked_func): |
| 38 self.mock_current_user(user_email='test@chromium.org', is_admin=True) |
| 39 |
| 40 response = self.test_app.post( |
| 41 '/process-flake-analysis-request', |
| 42 params=pickle.dumps(('request', 'email', False))) |
| 43 self.assertEquals(200, response.status_int) |
| 44 mocked_func.assert_call_with(mock.call('request', 'email', False)) |
| OLD | NEW |