Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from datetime import datetime | |
| 6 | |
| 7 import unittest | |
| 8 | |
| 9 from model import analysis_status | |
| 10 from model.flake.master_flake_analysis import MasterFlakeAnalysis | |
| 11 | |
| 12 | |
| 13 class MasterFlakeAnalysisTest(unittest.TestCase): | |
| 14 | |
| 15 def testMasterFlakeAnalysisStatusIsCompleted(self): | |
| 16 for status in (analysis_status.COMPLETED, analysis_status.ERROR): | |
| 17 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 18 analysis.status = status | |
| 19 self.assertTrue(analysis.completed) | |
| 20 | |
| 21 def testMasterFlakeAnalysisStatusIsNotCompleted(self): | |
| 22 for status in (analysis_status.PENDING, analysis_status.RUNNING): | |
| 23 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 24 analysis.status = status | |
| 25 self.assertFalse(analysis.completed) | |
| 26 | |
| 27 def testMasterFlakeAnalysisDurationWhenNotCompleted(self): | |
| 28 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 29 analysis.status = analysis_status.RUNNING | |
| 30 self.assertIsNone(analysis.duration) | |
| 31 | |
| 32 def testMasterFlakeAnalysisDurationWhenStartTimeNotSet(self): | |
| 33 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 34 analysis.status = analysis_status.COMPLETED | |
| 35 analysis.end_time = datetime(2015, 07, 30, 21, 15, 30, 40) | |
| 36 self.assertIsNone(analysis.duration) | |
| 37 | |
| 38 def testMasterFlakeAnalysisDurationWhenEndTimeNotSet(self): | |
| 39 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 40 analysis.status = analysis_status.COMPLETED | |
| 41 analysis.start_time = datetime(2015, 07, 30, 21, 15, 30, 40) | |
| 42 self.assertIsNone(analysis.duration) | |
| 43 | |
| 44 def testMasterFlakeAnalysisDurationWhenCompleted(self): | |
| 45 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 46 analysis.status = analysis_status.COMPLETED | |
| 47 analysis.start_time = datetime(2015, 07, 30, 21, 15, 30, 40) | |
| 48 analysis.end_time = datetime(2015, 07, 30, 21, 16, 15, 50) | |
| 49 self.assertEqual(45, analysis.duration) | |
| 50 | |
| 51 def testMasterFlakeAnalysisStatusIsFailed(self): | |
| 52 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 53 analysis.status = analysis_status.ERROR | |
| 54 self.assertTrue(analysis.failed) | |
| 55 | |
| 56 def testMasterFlakeAnalysisStatusIsNotFailed(self): | |
| 57 for status in (analysis_status.PENDING, analysis_status.RUNNING, | |
| 58 analysis_status.COMPLETED): | |
| 59 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 60 analysis.status = status | |
| 61 self.assertFalse(analysis.failed) | |
| 62 | |
| 63 def testMasterFlakeAnalysisStatusDescription(self): | |
| 64 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 65 analysis.status = analysis_status.PENDING | |
|
lijeffrey
2016/07/27 21:28:30
you're going to hate me for this but this test loo
| |
| 66 self.assertEqual('Pending', analysis.status_description) | |
| 67 analysis.status = analysis_status.RUNNING | |
| 68 self.assertEqual('Running', analysis.status_description) | |
| 69 analysis.status = analysis_status.COMPLETED | |
| 70 self.assertEqual('Completed', analysis.status_description) | |
| 71 analysis.status = analysis_status.ERROR | |
| 72 self.assertEqual('Error', analysis.status_description) | |
| 73 | |
| 74 def testMasterFlakeAnalysisStepTestName(self): | |
| 75 analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't') | |
| 76 self.assertEqual('s', analysis.step_name) | |
| 77 self.assertEqual('t', analysis.test_name) | |
| OLD | NEW |