| Index: appengine/findit/handlers/test/process_flake_analysis_request_test.py
|
| diff --git a/appengine/findit/handlers/test/process_flake_analysis_request_test.py b/appengine/findit/handlers/test/process_flake_analysis_request_test.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a08e020443d0804543781a1f3a4cff4c5fa1b2b0
|
| --- /dev/null
|
| +++ b/appengine/findit/handlers/test/process_flake_analysis_request_test.py
|
| @@ -0,0 +1,44 @@
|
| +# Copyright 2016 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import mock
|
| +import pickle
|
| +import re
|
| +
|
| +from google.appengine.ext import testbed
|
| +import webapp2
|
| +import webtest
|
| +
|
| +from testing_utils import testing
|
| +
|
| +from handlers import process_flake_analysis_request
|
| +
|
| +
|
| +class ProcessFlakeAnalysisRequestsTest(testing.AppengineTestCase):
|
| + app_module = webapp2.WSGIApplication([
|
| + ('/process-flake-analysis-request',
|
| + process_flake_analysis_request.ProcessFlakeAnalysisRequest),
|
| + ], debug=True)
|
| +
|
| + def testNonAdminCanNotSendRequest(self):
|
| + self.assertRaisesRegexp(
|
| + webtest.app.AppError,
|
| + re.compile('.*401 Unauthorized.*'
|
| + 'Error: Either not login or no permission.*',
|
| + re.MULTILINE | re.DOTALL),
|
| + self.test_app.post,
|
| + '/process-flake-analysis-request',
|
| + params='')
|
| +
|
| + @mock.patch.object(
|
| + process_flake_analysis_request.flake_analysis_service,
|
| + 'ScheduleAnalysisForFlake')
|
| + def testAdminCanRequestAnalysis(self, mocked_func):
|
| + self.mock_current_user(user_email='test@chromium.org', is_admin=True)
|
| +
|
| + response = self.test_app.post(
|
| + '/process-flake-analysis-request',
|
| + params=pickle.dumps(('request', 'email', False)))
|
| + self.assertEquals(200, response.status_int)
|
| + mocked_func.assert_call_with(mock.call('request', 'email', False))
|
|
|