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

Unified Diff: appengine/findit/handlers/test/process_flake_analysis_request_test.py

Issue 2435983003: [Findit] Asynchronously process flake reports from chromium-try-flakes. (Closed)
Patch Set: Rebase to resolve conflict Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/handlers/process_flake_analysis_request.py ('k') | appengine/findit/main.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
« no previous file with comments | « appengine/findit/handlers/process_flake_analysis_request.py ('k') | appengine/findit/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698