| 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 from testing_utils import testing | 5 from testing_utils import testing |
| 6 | 6 |
| 7 from common import buildbucket_client | 7 from common import buildbucket_client |
| 8 from model import wf_analysis_status | 8 from model import wf_analysis_status |
| 9 from model.wf_try_job import WfTryJob | 9 from model.wf_try_job import WfTryJob |
| 10 from waterfall.monitor_try_job_pipeline import MonitorTryJobPipeline | 10 from waterfall.monitor_try_job_pipeline import MonitorTryJobPipeline |
| 11 | 11 |
| 12 |
| 12 class MonitorTryJobPipelineTest(testing.AppengineTestCase): | 13 class MonitorTryJobPipelineTest(testing.AppengineTestCase): |
| 14 |
| 13 def _Mock_GetTryJobs(self, build_id): | 15 def _Mock_GetTryJobs(self, build_id): |
| 14 def Mocked_GetTryJobs(*_): | 16 def Mocked_GetTryJobs(*_): |
| 15 data = { | 17 data = { |
| 16 '1': { | 18 '1': { |
| 17 'build': { | 19 'build': { |
| 18 'id': '1', | 20 'id': '1', |
| 19 'url': 'url', | 21 'url': 'url', |
| 20 'status': 'COMPLETED', | 22 'status': 'COMPLETED', |
| 21 'result_details_json': ( | 23 'result_details_json': ( |
| 22 '{"properties": {"result": [["rev1", "passed"],' | 24 '{"properties": {"result": [["rev1", "passed"],' |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 | 45 |
| 44 def testGetTryJobsForCompileSuccess(self): | 46 def testGetTryJobsForCompileSuccess(self): |
| 45 master_name = 'm' | 47 master_name = 'm' |
| 46 builder_name = 'b' | 48 builder_name = 'b' |
| 47 build_number = 1 | 49 build_number = 1 |
| 48 try_job_id = '1' | 50 try_job_id = '1' |
| 49 | 51 |
| 50 try_job = WfTryJob.Create(master_name, builder_name, build_number) | 52 try_job = WfTryJob.Create(master_name, builder_name, build_number) |
| 51 try_job.compile_results = [ | 53 try_job.compile_results = [ |
| 52 { | 54 { |
| 53 'result': None, | 55 'report': None, |
| 54 'url': 'url', | 56 'url': 'url', |
| 55 'try_job_id': '1', | 57 'try_job_id': '1', |
| 56 } | 58 } |
| 57 ] | 59 ] |
| 58 try_job.status = wf_analysis_status.ANALYZING | 60 try_job.status = wf_analysis_status.ANALYZING |
| 59 try_job.put() | 61 try_job.put() |
| 60 self._Mock_GetTryJobs(try_job_id) | 62 self._Mock_GetTryJobs(try_job_id) |
| 61 | 63 |
| 62 pipeline = MonitorTryJobPipeline() | 64 pipeline = MonitorTryJobPipeline() |
| 63 compile_result = pipeline.run( | 65 compile_result = pipeline.run( |
| 64 master_name, builder_name, build_number, try_job_id) | 66 master_name, builder_name, build_number, try_job_id) |
| 65 | 67 |
| 66 expected_compile_result = { | 68 expected_compile_result = { |
| 67 'result': [ | 69 'report': [ |
| 68 ['rev1', 'passed'], | 70 ['rev1', 'passed'], |
| 69 ['rev2', 'failed'] | 71 ['rev2', 'failed'] |
| 70 ], | 72 ], |
| 71 'url': 'url', | 73 'url': 'url', |
| 72 'try_job_id': '1', | 74 'try_job_id': '1', |
| 73 } | 75 } |
| 74 self.assertEqual(expected_compile_result, compile_result) | 76 self.assertEqual(expected_compile_result, compile_result) |
| 75 | 77 |
| 76 try_job = WfTryJob.Get(master_name, builder_name, build_number) | 78 try_job = WfTryJob.Get(master_name, builder_name, build_number) |
| 77 self.assertEqual(expected_compile_result, try_job.compile_results[-1]) | 79 self.assertEqual(expected_compile_result, try_job.compile_results[-1]) |
| 78 self.assertEqual(wf_analysis_status.ANALYZING, try_job.status) | 80 self.assertEqual(wf_analysis_status.ANALYZING, try_job.status) |
| OLD | NEW |