| 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 | 4 |
| 5 import unittest | 5 from gae_libs.testcase import TestCase |
| 6 | 6 |
| 7 from model import analysis_status | |
| 8 from model.wf_try_job import WfTryJob | 7 from model.wf_try_job import WfTryJob |
| 9 | 8 |
| 10 | 9 |
| 11 class WfTryJobTest(unittest.TestCase): | 10 class WfTryJobTest(TestCase): |
| 12 def testWfTryJobStatusIsCompleted(self): | |
| 13 for status in (analysis_status.COMPLETED, analysis_status.ERROR): | |
| 14 try_job = WfTryJob.Create('m', 'b', 123) | |
| 15 try_job.status = status | |
| 16 self.assertTrue(try_job.completed) | |
| 17 | 11 |
| 18 def testWfTryJobStatusIsNotCompleted(self): | 12 def testCreate(self): |
| 19 for status in (analysis_status.PENDING, analysis_status.RUNNING): | 13 try_job = WfTryJob.Create('m', 'b', 123) |
| 20 try_job = WfTryJob.Create('m', 'b', 123) | 14 self.assertEqual([], try_job.try_job_ids) |
| 21 try_job.status = status | 15 self.assertEqual([], try_job.compile_results) |
| 22 self.assertFalse(try_job.completed) | 16 self.assertEqual([], try_job.test_results) |
| 23 | 17 |
| 24 def testWfTryJobStatusIsFailed(self): | 18 def testGet(self): |
| 25 try_job = WfTryJob.Create('m', 'b', 123) | 19 master_name = 'm' |
| 26 try_job.status = analysis_status.ERROR | 20 builder_name = 'b' |
| 27 self.assertTrue(try_job.failed) | 21 build_number = 123 |
| 22 try_job_id = 'try_job_id' |
| 28 | 23 |
| 29 def testWfTryJobStatusIsNotFailed(self): | 24 try_job_before = WfTryJob.Create(master_name, builder_name, build_number) |
| 30 for status in (analysis_status.PENDING, analysis_status.RUNNING, | 25 try_job_before.try_job_ids = [try_job_id] |
| 31 analysis_status.COMPLETED): | 26 try_job_before.put() |
| 32 try_job = WfTryJob.Create('m', 'b', 123) | 27 |
| 33 try_job.status = status | 28 try_job_after = WfTryJob.Get(master_name, builder_name, build_number) |
| 34 self.assertFalse(try_job.failed) | 29 self.assertEqual([try_job_id], try_job_after.try_job_ids) |
| OLD | NEW |