| 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 filter_latest_jobs | 10 from webkitpy.common.net.rietveld import filter_latest_jobs |
| 11 from webkitpy.common.net.rietveld import get_latest_try_job_results | 11 from webkitpy.common.net.rietveld import get_latest_try_job_results |
| 12 from webkitpy.common.net.rietveld import latest_try_jobs | 12 from webkitpy.common.net.rietveld import latest_try_jobs |
| 13 from webkitpy.common.net.rietveld import changed_files |
| 13 from webkitpy.common.net.buildbot import Build | 14 from webkitpy.common.net.buildbot import Build |
| 14 from webkitpy.common.net.web_mock import MockWeb | 15 from webkitpy.common.net.web_mock import MockWeb |
| 15 from webkitpy.common.system.outputcapture import OutputCapture | 16 from webkitpy.common.system.outputcapture import OutputCapture |
| 16 | 17 |
| 17 | 18 |
| 18 _log = logging.getLogger(__name__) | 19 _log = logging.getLogger(__name__) |
| 19 | 20 |
| 20 | 21 |
| 21 class RietveldTest(unittest.TestCase): | 22 class RietveldTest(unittest.TestCase): |
| 22 | 23 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 45 'builder': 'foo-builder', | 46 'builder': 'foo-builder', |
| 46 'buildnumber': 20, | 47 'buildnumber': 20, |
| 47 'result': 1 | 48 'result': 1 |
| 48 }, | 49 }, |
| 49 { | 50 { |
| 50 'builder': 'bar-builder', | 51 'builder': 'bar-builder', |
| 51 'buildnumber': 60, | 52 'buildnumber': 60, |
| 52 'result': 0 | 53 'result': 0 |
| 53 }, | 54 }, |
| 54 ], | 55 ], |
| 56 'files': { |
| 57 'some/path/foo.cc': {'status': 'M'}, |
| 58 'some/path/bar.html': {'status': 'M'}, |
| 59 } |
| 55 }), | 60 }), |
| 56 'https://codereview.chromium.org/api/11113333': 'my non-JSON content
s', | 61 'https://codereview.chromium.org/api/11113333': 'my non-JSON content
s', |
| 57 }) | 62 }) |
| 58 | 63 |
| 59 def test_latest_try_jobs(self): | 64 def test_latest_try_jobs(self): |
| 60 self.assertEqual( | 65 self.assertEqual( |
| 61 latest_try_jobs(11112222, ('bar-builder', 'other-builder'), self.web
), | 66 latest_try_jobs(11112222, ('bar-builder', 'other-builder'), self.web
), |
| 62 [Build('bar-builder', 60)]) | 67 [Build('bar-builder', 60)]) |
| 63 | 68 |
| 64 def test_latest_try_jobs_http_error(self): | 69 def test_latest_try_jobs_http_error(self): |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 108 |
| 104 def test_filter_latest_jobs_higher_build_last(self): | 109 def test_filter_latest_jobs_higher_build_last(self): |
| 105 self.assertEqual( | 110 self.assertEqual( |
| 106 filter_latest_jobs([Build('foo', 3), Build('bar', 5), Build('foo', 5
)]), | 111 filter_latest_jobs([Build('foo', 3), Build('bar', 5), Build('foo', 5
)]), |
| 107 [Build('bar', 5), Build('foo', 5)]) | 112 [Build('bar', 5), Build('foo', 5)]) |
| 108 | 113 |
| 109 def test_filter_latest_jobs_no_build_number(self): | 114 def test_filter_latest_jobs_no_build_number(self): |
| 110 self.assertEqual( | 115 self.assertEqual( |
| 111 filter_latest_jobs([Build('foo', 3), Build('bar')]), | 116 filter_latest_jobs([Build('foo', 3), Build('bar')]), |
| 112 [Build('foo', 3)]) | 117 [Build('foo', 3)]) |
| 118 |
| 119 def test_changed_files(self): |
| 120 self.assertEqual( |
| 121 changed_files(11112222, self.web), |
| 122 ['some/path/bar.html', 'some/path/foo.cc']) |
| 123 |
| 124 def test_changed_files_no_results(self): |
| 125 self.assertIsNone(changed_files(11113333, self.web)) |
| OLD | NEW |