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

Side by Side Diff: appengine/findit/handlers/test/list_analyses_test.py

Issue 2230103002: [Findit] Pipeline change to save suspected cls to data store. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@0808-resubmit-suspected_cl_model
Patch Set: rebase 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 import datetime 4 import datetime
5 5
6 import webapp2 6 import webapp2
7 7
8 from testing_utils import testing 8 from testing_utils import testing
9 9
10 from handlers import list_analyses 10 from handlers import list_analyses
(...skipping 15 matching lines...) Expand all
26 def testListAnalysesHandler(self): 26 def testListAnalysesHandler(self):
27 response = self.test_app.get('/list-analyses') 27 response = self.test_app.get('/list-analyses')
28 self.assertEqual(200, response.status_int) 28 self.assertEqual(200, response.status_int)
29 29
30 def _AddAnalysisResult(self, master_name, builder_name, build_number): 30 def _AddAnalysisResult(self, master_name, builder_name, build_number):
31 analysis = WfAnalysis.Create(master_name, builder_name, build_number) 31 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
32 analysis.status = analysis_status.RUNNING 32 analysis.status = analysis_status.RUNNING
33 analysis.put() 33 analysis.put()
34 return analysis 34 return analysis
35 35
36 def _GetSuspectedCLs(self, analysis_result):
37 """Returns the suspected CLs we found in analysis."""
38 suspected_cls = []
39 if not analysis_result or not analysis_result['failures']:
40 return suspected_cls
41
42 for failure in analysis_result['failures']:
43 for suspected_cl in failure['suspected_cls']:
44 cl_info = {
45 'repo_name': suspected_cl['repo_name'],
46 'revision': suspected_cl['revision'],
47 'commit_position': suspected_cl['commit_position'],
48 'url': suspected_cl['url']
49 }
50 if cl_info not in suspected_cls:
51 suspected_cls.append(cl_info)
52 return suspected_cls
53
36 def _AddAnalysisResults(self): 54 def _AddAnalysisResults(self):
37 """Create and store dummy data.""" 55 """Create and store dummy data."""
38 analyses = [] 56 analyses = []
39 stored_dates = {} 57 stored_dates = {}
40 def StoreTestBuildDate(analysis_number, start_time): 58 def StoreTestBuildDate(analysis_number, start_time):
41 if datetime: # pragma: no cover 59 if datetime: # pragma: no cover
42 stored_dates[analysis_number] = start_time.strftime( 60 stored_dates[analysis_number] = start_time.strftime(
43 '%Y-%m-%d %H:%M:%S UTC') 61 '%Y-%m-%d %H:%M:%S UTC')
44 62
45 for i in range(0, 10): 63 for i in range(0, 10):
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 'hints': { 256 'hints': {
239 'modified x/f99_9.cc (and it was in log)': 1, 257 'modified x/f99_9.cc (and it was in log)': 1,
240 }, 258 },
241 } 259 }
242 ], 260 ],
243 } 261 }
244 ] 262 ]
245 } 263 }
246 264
247 for analysis in analyses: 265 for analysis in analyses:
248 analysis.suspected_cls = identify_culprit_pipeline._GetSuspectedCLs( 266 analysis.suspected_cls = self._GetSuspectedCLs(analysis.result)
249 analysis.result)
250 analysis.result_status = (identify_culprit_pipeline. 267 analysis.result_status = (identify_culprit_pipeline.
251 _GetResultAnalysisStatus(analysis.result)) 268 _GetResultAnalysisStatus(analysis.result))
252 analysis.put() 269 analysis.put()
253 270
254 analyses[1].result_status = result_status.FOUND_INCORRECT 271 analyses[1].result_status = result_status.FOUND_INCORRECT
255 analyses[1].put() 272 analyses[1].put()
256 analyses[3].result_status = result_status.NOT_FOUND_INCORRECT 273 analyses[3].result_status = result_status.NOT_FOUND_INCORRECT
257 analyses[3].put() 274 analyses[3].put()
258 analyses[10].result_status = result_status.FOUND_CORRECT 275 analyses[10].result_status = result_status.FOUND_CORRECT
259 analyses[10].put() 276 analyses[10].put()
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 'triage': '-1', 605 'triage': '-1',
589 'days': '6', 606 'days': '6',
590 'count': '-1', 607 'count': '-1',
591 'result_status': '0' 608 'result_status': '0'
592 } 609 }
593 610
594 response_json = self.test_app.get( 611 response_json = self.test_app.get(
595 '/list-analyses?format=json&result_status=0&days=6') 612 '/list-analyses?format=json&result_status=0&days=6')
596 self.assertEqual(200, response_json.status_int) 613 self.assertEqual(200, response_json.status_int)
597 self.assertEqual(expected_result, response_json.json_body) 614 self.assertEqual(expected_result, response_json.json_body)
OLDNEW
« no previous file with comments | « appengine/findit/handlers/test/build_failure_test.py ('k') | appengine/findit/model/base_suspected_cl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698