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

Side by Side Diff: appengine/findit/handlers/flake/test/check_flake_test.py

Issue 2369333002: [Findit] Capture versionized metadata for master_flake_analysis (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 2016 The Chromium Authors. All rights reserved. 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 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 re 5 import re
6 6
7 import webapp2 7 import webapp2
8 import webtest 8 import webtest
9 9
10 from handlers.flake import check_flake 10 from handlers.flake import check_flake
11 from model.flake.master_flake_analysis import MasterFlakeAnalysis 11 from model.flake.master_flake_analysis import MasterFlakeAnalysis
12 from model import analysis_status 12 from model import analysis_status
13 from model.analysis_status import STATUS_TO_DESCRIPTION 13 from model.analysis_status import STATUS_TO_DESCRIPTION
14 from waterfall.test import wf_testcase 14 from waterfall.test import wf_testcase
15 15
16 16
17 class CheckFlakeTest(wf_testcase.WaterfallTestCase): 17 class CheckFlakeTest(wf_testcase.WaterfallTestCase):
18 app_module = webapp2.WSGIApplication([ 18 app_module = webapp2.WSGIApplication([
19 ('/waterfall/check-flake', check_flake.CheckFlake), 19 ('/waterfall/check-flake', check_flake.CheckFlake),
20 ], debug=True) 20 ], debug=True)
21 21
22 def _CreateAndSaveMasterFlakeAnalysis(
23 self, master_name, builder_name, build_number,
24 step_name, test_name, status):
25 analysis = MasterFlakeAnalysis.Create(
26 master_name, builder_name, build_number, step_name, test_name)
27 analysis.status = status
28 analysis.put()
29 return analysis
30
31 def testCorpUserCanScheduleANewAnalysis(self): 22 def testCorpUserCanScheduleANewAnalysis(self):
32 master_name = 'm' 23 master_name = 'm'
33 builder_name = 'b' 24 builder_name = 'b'
34 build_number = '123' 25 build_number = '123'
35 step_name = 's' 26 step_name = 's'
36 test_name = 't' 27 test_name = 't'
37 28
38 self.mock_current_user(user_email='test@google.com') 29 self.mock_current_user(user_email='test@google.com')
39 30
40 response = self.test_app.get('/waterfall/check-flake', params={ 31 response = self.test_app.get('/waterfall/check-flake', params={
(...skipping 26 matching lines...) Expand all
67 'test_name': test_name 58 'test_name': test_name
68 }) 59 })
69 60
70 def testAnyoneCanViewScheduledAnalysis(self): 61 def testAnyoneCanViewScheduledAnalysis(self):
71 master_name = 'm' 62 master_name = 'm'
72 builder_name = 'b' 63 builder_name = 'b'
73 build_number = '123' 64 build_number = '123'
74 step_name = 's' 65 step_name = 's'
75 test_name = 't' 66 test_name = 't'
76 success_rate = .9 67 success_rate = .9
77 status = analysis_status.PENDING
78 68
79 master_flake_analysis = self._CreateAndSaveMasterFlakeAnalysis( 69 master_flake_analysis = MasterFlakeAnalysis.Create(
80 master_name, builder_name, build_number, step_name, 70 master_name, builder_name, build_number, step_name, test_name)
81 test_name, status) 71 master_flake_analysis.status = analysis_status.PENDING
82 master_flake_analysis.build_numbers.append(int(build_number)) 72 master_flake_analysis.build_numbers.append(int(build_number))
83 master_flake_analysis.success_rates.append(success_rate) 73 master_flake_analysis.pass_rates.append(success_rate)
84 master_flake_analysis.put() 74 master_flake_analysis.Save()
85 75
86 response = self.test_app.get('/waterfall/check-flake', params={ 76 response = self.test_app.get('/waterfall/check-flake', params={
87 'master_name': master_name, 77 'master_name': master_name,
88 'builder_name': builder_name, 78 'builder_name': builder_name,
89 'build_number': build_number, 79 'build_number': build_number,
90 'step_name': step_name, 80 'step_name': step_name,
91 'test_name': test_name, 81 'test_name': test_name,
92 'format': 'json'}) 82 'format': 'json'})
93 83
94 self.assertEquals(200, response.status_int) 84 expected_check_flake_result = {
95 expected_check_flake_result ={ 85 'pass_rates': [[int(build_number), success_rate]],
96 'success_rates': [[int(build_number), success_rate]],
97 'analysis_status': STATUS_TO_DESCRIPTION.get( 86 'analysis_status': STATUS_TO_DESCRIPTION.get(
98 master_flake_analysis.status), 87 master_flake_analysis.status),
99 'master_name': master_name, 88 'master_name': master_name,
100 'builder_name': builder_name, 89 'builder_name': builder_name,
101 'build_number': int(build_number), 90 'build_number': int(build_number),
102 'step_name': step_name, 91 'step_name': step_name,
103 'test_name': test_name, 92 'test_name': test_name,
104 'suspected_flake_build_number': None 93 'suspected_flake_build_number': None
105 } 94 }
95
96 self.assertEquals(200, response.status_int)
106 self.assertEqual(expected_check_flake_result, response.json_body) 97 self.assertEqual(expected_check_flake_result, response.json_body)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698