| OLD | NEW |
| 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 from datetime import datetime | 5 from datetime import datetime |
| 6 | 6 |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 from model import analysis_status | 9 from model import analysis_status |
| 10 from model import result_status |
| 11 from model import triage_status |
| 10 from model.flake.master_flake_analysis import DataPoint | 12 from model.flake.master_flake_analysis import DataPoint |
| 11 from model.flake.master_flake_analysis import MasterFlakeAnalysis | 13 from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| 12 | 14 |
| 13 | 15 |
| 14 class MasterFlakeAnalysisTest(unittest.TestCase): | 16 class MasterFlakeAnalysisTest(unittest.TestCase): |
| 15 | 17 |
| 16 def testMasterFlakeAnalysisStatusIsCompleted(self): | 18 def testMasterFlakeAnalysisStatusIsCompleted(self): |
| 17 for status in (analysis_status.COMPLETED, analysis_status.ERROR): | 19 for status in (analysis_status.COMPLETED, analysis_status.ERROR): |
| 18 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | 20 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') |
| 19 analysis.status = status | 21 analysis.status = status |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 def testMasterFlakeAnalysisStatusDescriptionError(self): | 81 def testMasterFlakeAnalysisStatusDescriptionError(self): |
| 80 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | 82 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') |
| 81 analysis.status = analysis_status.ERROR | 83 analysis.status = analysis_status.ERROR |
| 82 self.assertEqual('Error', analysis.status_description) | 84 self.assertEqual('Error', analysis.status_description) |
| 83 | 85 |
| 84 def testMasterFlakeAnalysisStepTestName(self): | 86 def testMasterFlakeAnalysisStepTestName(self): |
| 85 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | 87 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') |
| 86 self.assertEqual('s', analysis.step_name) | 88 self.assertEqual('s', analysis.step_name) |
| 87 self.assertEqual('t', analysis.test_name) | 89 self.assertEqual('t', analysis.test_name) |
| 88 | 90 |
| 91 def testMasterFlakeAnalysisUpdateTriageResultCorrect(self): |
| 92 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') |
| 93 analysis.UpdateTriageResult( |
| 94 triage_status.TRIAGED_CORRECT, {'build_number': 100}, 'test') |
| 95 self.assertEqual(analysis.result_status, result_status.FOUND_CORRECT) |
| 96 |
| 97 def testMasterFlakeAnalysisUpdateTriageResultIncorrect(self): |
| 98 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') |
| 99 analysis.UpdateTriageResult( |
| 100 triage_status.TRIAGED_INCORRECT, {'build_number': 100}, 'test') |
| 101 self.assertEqual(analysis.result_status, result_status.FOUND_INCORRECT) |
| 102 |
| 89 def testReset(self): | 103 def testReset(self): |
| 90 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | 104 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') |
| 91 analysis.swarming_rerun_results = [{}] | 105 analysis.swarming_rerun_results = [{}] |
| 92 analysis.status = analysis_status.RUNNING | 106 analysis.status = analysis_status.RUNNING |
| 93 analysis.correct_regression_range = True | 107 analysis.correct_regression_range = True |
| 94 analysis.correct_culprit = False | 108 analysis.correct_culprit = False |
| 95 analysis.correct_culprit = None | 109 analysis.correct_culprit = None |
| 96 analysis.data_points = [DataPoint()] | 110 analysis.data_points = [DataPoint()] |
| 97 analysis.suspected_flake_build_number = 123 | 111 analysis.suspected_flake_build_number = 123 |
| 98 analysis.Reset() | 112 analysis.Reset() |
| (...skipping 17 matching lines...) Expand all Loading... |
| 116 | 130 |
| 117 def testGetIterationsToRerun(self): | 131 def testGetIterationsToRerun(self): |
| 118 cases = [ | 132 cases = [ |
| 119 (-1, {}), | 133 (-1, {}), |
| 120 (5, {'key': 'value', 'iterations_to_rerun': 5}), | 134 (5, {'key': 'value', 'iterations_to_rerun': 5}), |
| 121 ] | 135 ] |
| 122 for expected_rerun, algorithm_parameters in cases: | 136 for expected_rerun, algorithm_parameters in cases: |
| 123 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | 137 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') |
| 124 analysis.algorithm_parameters = algorithm_parameters | 138 analysis.algorithm_parameters = algorithm_parameters |
| 125 self.assertEqual(expected_rerun, analysis.iterations_to_rerun) | 139 self.assertEqual(expected_rerun, analysis.iterations_to_rerun) |
| OLD | NEW |