Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld_unittest.py

Issue 2718503004: Remove Rietveld class and all dependencies on it. (Closed)
Patch Set: Rebased Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 import json
6 import urllib2
7
8 from webkitpy.common.net.rietveld import Rietveld
9 from webkitpy.common.net.buildbot import Build
10 from webkitpy.common.net.web_mock import MockWeb
11 from webkitpy.common.system.log_testing import LoggingTestCase
12
13
14 class RietveldTest(LoggingTestCase):
15
16 def mock_web(self):
17 return MockWeb(urls={
18 'https://codereview.chromium.org/api/11112222': json.dumps({
19 'patchsets': [1, 2, 3],
20 }),
21 'https://codereview.chromium.org/api/11112222/2': json.dumps({
22 'try_job_results': [
23 {
24 'builder': 'foo-builder',
25 'buildnumber': None,
26 'result': -1
27 },
28 {
29 'builder': 'bar-builder',
30 'buildnumber': 50,
31 'result': 0
32 },
33 ],
34 }),
35 'https://codereview.chromium.org/api/11112222/3': json.dumps({
36 'try_job_results': [
37 {
38 'builder': 'foo-builder',
39 'buildnumber': 20,
40 'result': 1
41 },
42 {
43 'builder': 'bar-builder',
44 'buildnumber': 60,
45 'result': 0
46 },
47 ],
48 'files': {
49 'some/path/foo.cc': {'status': 'M'},
50 'some/path/bar.html': {'status': 'M'},
51 'some/path/deleted.html': {'status': 'D'},
52 }
53 }),
54 'https://codereview.chromium.org/api/11113333': 'my non-JSON content s',
55 })
56
57 def test_latest_try_jobs(self):
58 rietveld = Rietveld(self.mock_web())
59 self.assertEqual(
60 rietveld.latest_try_jobs(11112222, ('bar-builder', 'other-builder')) ,
61 [Build('bar-builder', 60)])
62
63 def test_latest_try_jobs_http_error(self):
64 def raise_error(_):
65 raise urllib2.URLError('Some request error message')
66 web = self.mock_web()
67 web.get_binary = raise_error
68 rietveld = Rietveld(web)
69 self.assertEqual(rietveld.latest_try_jobs(11112222, ('bar-builder',)), [ ])
70 self.assertLog(['ERROR: Request failed to URL: https://codereview.chromi um.org/api/11112222\n'])
71
72 def test_latest_try_jobs_non_json_response(self):
73 rietveld = Rietveld(self.mock_web())
74 self.assertEqual(rietveld.latest_try_jobs(11113333, ('bar-builder',)), [ ])
75 self.assertLog(['ERROR: Invalid JSON: my non-JSON contents\n'])
76
77 def test_latest_try_jobs_with_patchset(self):
78 rietveld = Rietveld(self.mock_web())
79 self.assertEqual(
80 rietveld.latest_try_jobs(11112222, ('bar-builder', 'other-builder'), patchset_number=2),
81 [Build('bar-builder', 50)])
82
83 def test_latest_try_jobs_no_relevant_builders(self):
84 rietveld = Rietveld(self.mock_web())
85 self.assertEqual(rietveld.latest_try_jobs(11112222, ('foo', 'bar')), [])
86
87 def test_changed_files(self):
88 rietveld = Rietveld(self.mock_web())
89 self.assertEqual(
90 rietveld.changed_files(11112222),
91 ['some/path/bar.html', 'some/path/foo.cc'])
92
93 def test_changed_files_no_results(self):
94 rietveld = Rietveld(self.mock_web())
95 self.assertIsNone(rietveld.changed_files(11113333))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698