| 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 import json | 5 import json |
| 6 import logging | 6 import logging |
| 7 import unittest | 7 import unittest |
| 8 import urllib2 | 8 import urllib2 |
| 9 | 9 |
| 10 from webkitpy.common.net.rietveld import latest_try_jobs, TryJob, get_latest_try
_job_results | 10 from webkitpy.common.net.rietveld import filter_latest_jobs |
| 11 from webkitpy.common.net.rietveld import get_latest_try_job_results |
| 12 from webkitpy.common.net.rietveld import latest_try_jobs |
| 13 from webkitpy.common.net.rietveld import TryJob |
| 11 from webkitpy.common.net.web_mock import MockWeb | 14 from webkitpy.common.net.web_mock import MockWeb |
| 12 from webkitpy.common.system.outputcapture import OutputCapture | 15 from webkitpy.common.system.outputcapture import OutputCapture |
| 13 | 16 |
| 14 | 17 |
| 15 _log = logging.getLogger(__name__) | 18 _log = logging.getLogger(__name__) |
| 16 | 19 |
| 17 | 20 |
| 18 class RietveldTest(unittest.TestCase): | 21 class RietveldTest(unittest.TestCase): |
| 19 | 22 |
| 20 def setUp(self): | 23 def setUp(self): |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 def test_latest_try_jobs_with_patchset(self): | 85 def test_latest_try_jobs_with_patchset(self): |
| 83 self.assertEqual( | 86 self.assertEqual( |
| 84 latest_try_jobs(11112222, ('bar-builder', 'other-builder'), self.web
, patchset_number=2), | 87 latest_try_jobs(11112222, ('bar-builder', 'other-builder'), self.web
, patchset_number=2), |
| 85 [TryJob('bar-builder', 50)]) | 88 [TryJob('bar-builder', 50)]) |
| 86 | 89 |
| 87 def test_latest_try_jobs_no_relevant_builders(self): | 90 def test_latest_try_jobs_no_relevant_builders(self): |
| 88 self.assertEqual(latest_try_jobs(11112222, ('foo', 'bar'), self.web), []
) | 91 self.assertEqual(latest_try_jobs(11112222, ('foo', 'bar'), self.web), []
) |
| 89 | 92 |
| 90 def test_get_latest_try_job_results(self): | 93 def test_get_latest_try_job_results(self): |
| 91 self.assertEqual(get_latest_try_job_results(11112222, self.web), {'foo-b
uilder': 1, 'bar-builder': 0}) | 94 self.assertEqual(get_latest_try_job_results(11112222, self.web), {'foo-b
uilder': 1, 'bar-builder': 0}) |
| 95 |
| 96 def test_filter_latest_jobs_empty(self): |
| 97 self.assertEqual(filter_latest_jobs([]), []) |
| 98 |
| 99 def test_filter_latest_jobs_higher_build_first(self): |
| 100 self.assertEqual( |
| 101 filter_latest_jobs([ |
| 102 TryJob('foo', 5), |
| 103 TryJob('foo', 3), |
| 104 TryJob('bar', 5), |
| 105 ]), |
| 106 [ |
| 107 TryJob('foo', 5), |
| 108 TryJob('bar', 5), |
| 109 ]) |
| 110 |
| 111 def test_filter_latest_jobs_higher_build_last(self): |
| 112 self.assertEqual( |
| 113 filter_latest_jobs([ |
| 114 TryJob('foo', 3), |
| 115 TryJob('bar', 5), |
| 116 TryJob('foo', 5), |
| 117 ]), |
| 118 [ |
| 119 TryJob('bar', 5), |
| 120 TryJob('foo', 5), |
| 121 ]) |
| OLD | NEW |