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

Side by Side Diff: appengine/findit/test/findit_api_test.py

Issue 2397603002: [Findit] Cloud Endpoints API to receive reports on flakes. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 json 5 import json
6 import mock
7 import re
6 8
7 import endpoints 9 import endpoints
8 from google.appengine.api import taskqueue 10 from google.appengine.api import taskqueue
11 import webtest
9 12
10 from testing_utils import testing 13 from testing_utils import testing
11 14
12 from common.waterfall import failure_type 15 from common.waterfall import failure_type
13 import findit_api 16 import findit_api
14 from findit_api import FindItApi 17 from findit_api import FindItApi
15 from model.wf_analysis import WfAnalysis 18 from model.wf_analysis import WfAnalysis
16 from model.wf_swarming_task import WfSwarmingTask 19 from model.wf_swarming_task import WfSwarmingTask
17 from model.wf_try_job import WfTryJob 20 from model.wf_try_job import WfTryJob
18 from model import analysis_status 21 from model import analysis_status
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 'master_name': master_name, 698 'master_name': master_name,
696 'builder_name': builder_name, 699 'builder_name': builder_name,
697 'build_number': build_number, 700 'build_number': build_number,
698 'failed_steps': [], 701 'failed_steps': [],
699 }, 702 },
700 ] 703 ]
701 } 704 }
702 self.assertEqual( 705 self.assertEqual(
703 expected_payload_json, 706 expected_payload_json,
704 json.loads(self.taskqueue_requests[0].get('payload'))) 707 json.loads(self.taskqueue_requests[0].get('payload')))
708
709 @mock.patch.object(
710 findit_api.flake_analysis_service,
711 'ScheduleAnalysisForFlake', return_value=None)
712 def testUnauthorizedRequestToAnalyzeFlake(self, _mocked_object):
713 self.mock_current_user(user_email='test@chromium.org', is_admin=False)
714
715 flake = {
716 'name': 'suite.test',
717 'is_step': False,
718 'bug_id': 123,
719 'build_steps': [
720 {
721 'master_name': 'm',
722 'builder_name': 'b',
723 'build_number': 456,
724 'step_name': 'name (with patch) on Windows-7-SP1',
725 }
726 ]
727 }
728
729 self.assertRaisesRegexp(
730 webtest.app.AppError,
731 re.compile('.*401 Unauthorized.*',
732 re.MULTILINE | re.DOTALL),
733 self.call_api, 'AnalyzeFlake', body=flake)
734
735 @mock.patch.object(
736 findit_api.flake_analysis_service,
737 'ScheduleAnalysisForFlake', return_value=True)
738 def testAuthorizedRequestToAnalyzeFlake(self, _mocked_object):
739 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
740
741 flake = {
742 'name': 'suite.test',
743 'is_step': False,
744 'bug_id': 123,
745 'build_steps': [
746 {
747 'master_name': 'm',
748 'builder_name': 'b',
749 'build_number': 456,
750 'step_name': 'name (with patch) on Windows-7-SP1',
751 }
752 ]
753 }
754
755 response = self.call_api('AnalyzeFlake', body=flake)
756 self.assertEqual(200, response.status_int)
757 self.assertTrue(response.json_body.get('analysis_triggered'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698