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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..f8629e1baa68f72d32c18d6732d2361b8a27c439
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
@@ -0,0 +1,71 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+
+from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.executive_mock import MockExecutive2
+from webkitpy.w3c.test_exporter import TestExporter
+from webkitpy.w3c.wpt_github_mock import MockWPTGitHub
+
+
+class TestExporterTest(unittest.TestCase):
+
+ def test_stops_if_more_than_one_pr_is_in_flight(self):
+ host = MockHost()
+ wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}])
+
+ # TODO: make Exception more specific
+ with self.assertRaises(Exception):
+ TestExporter(host, wpt_github).run()
+
+ def test_if_pr_exists_merges_it(self):
+ host = MockHost()
+ wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}])
+ TestExporter(host, wpt_github).run()
+
+ self.assertIn('merge_pull_request', wpt_github.calls)
+
+ def test_merge_failure_errors_out(self):
+ host = MockHost()
+ wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}],
+ unsuccessful_merge=True)
+
+ # TODO: make Exception more specific
+ with self.assertRaises(Exception):
+ TestExporter(host, wpt_github).run()
+
+ def test_dry_run_stops_before_creating_pr(self):
+ host = MockHost()
+ host.executive = MockExecutive2(output='beefcafe')
+ wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}])
+ TestExporter(host, wpt_github, dry_run=True).run()
+
+ self.assertEqual(wpt_github.calls, ['in_flight_pull_requests'])
+
+ def test_creates_pull_request_for_earliest_commit(self):
+ host = MockHost()
+
+ def mock_command(args):
+ git_command = args[1]
+ if git_command == 'rev-list':
+ return 'facebeef\ncafedad5'
+ elif git_command == 'footers':
+ return 'fake-cr-position'
+ elif git_command == 'show':
+ if 'cafedad5' in args:
+ return 'newer fake text'
+ elif 'facebeef' in args:
+ return 'older fake text'
+ else:
+ return ''
+
+ host.executive = MockExecutive2(run_command_fn=mock_command)
+ wpt_github = MockWPTGitHub(pull_requests=[])
+
+ TestExporter(host, wpt_github).run()
+
+ self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_pr'])
+ self.assertEqual(wpt_github.pull_requests_created,
+ [('chromium-export-try', 'older fake text', 'older fake text')])

Powered by Google App Engine
This is Rietveld 408576698