| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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) |
| OLD | NEW |