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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py

Issue 2518313003: Refactor WPT Export to ensure only one PR in flight at a time (Closed)
Patch Set: Address CL feedback Created 4 years 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 unittest
6
7 from webkitpy.common.host_mock import MockHost
8 from webkitpy.common.system.executive_mock import MockExecutive2
9 from webkitpy.w3c.test_exporter import TestExporter
10 from webkitpy.w3c.wpt_github_mock import MockWPTGitHub
11
12
13 class TestExporterTest(unittest.TestCase):
14
15 def test_stops_if_more_than_one_pr_is_in_flight(self):
16 host = MockHost()
17 wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}])
18
19 # TODO: make Exception more specific
20 with self.assertRaises(Exception):
21 TestExporter(host, wpt_github).run()
22
23 def test_if_pr_exists_merges_it(self):
24 host = MockHost()
25 wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}] )
26 TestExporter(host, wpt_github).run()
27
28 self.assertIn('merge_pull_request', wpt_github.calls)
29
30 def test_merge_failure_errors_out(self):
31 host = MockHost()
32 wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}] ,
33 unsuccessful_merge=True)
34
35 # TODO: make Exception more specific
36 with self.assertRaises(Exception):
37 TestExporter(host, wpt_github).run()
38
39 def test_dry_run_stops_before_creating_pr(self):
40 host = MockHost()
41 host.executive = MockExecutive2(output='beefcafe')
42 wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}] )
43 TestExporter(host, wpt_github, dry_run=True).run()
44
45 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests'])
46
47 def test_creates_pull_request_for_earliest_commit(self):
48 host = MockHost()
49
50 def mock_command(args):
51 git_command = args[1]
52 if git_command == 'rev-list':
53 return 'facebeef\ncafedad5'
54 elif git_command == 'footers':
55 return 'fake-cr-position'
56 elif git_command == 'show':
57 if 'cafedad5' in args:
58 return 'newer fake text'
59 elif 'facebeef' in args:
60 return 'older fake text'
61 else:
62 return ''
63
64 host.executive = MockExecutive2(run_command_fn=mock_command)
65 wpt_github = MockWPTGitHub(pull_requests=[])
66
67 TestExporter(host, wpt_github).run()
68
69 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_p r'])
70 self.assertEqual(wpt_github.pull_requests_created,
71 [('chromium-export-try', 'older fake text', 'older fake text')])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698