Chromium Code Reviews| 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 |
| index f8629e1baa68f72d32c18d6732d2361b8a27c439..b2678d8eba9fa3423896a3c8c3caf6f9affe7226 100644 |
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py |
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py |
| @@ -6,12 +6,26 @@ import unittest |
| from webkitpy.common.host_mock import MockHost |
| from webkitpy.common.system.executive_mock import MockExecutive2 |
| +from webkitpy.w3c.chromium_commit import ChromiumCommit |
| from webkitpy.w3c.test_exporter import TestExporter |
| from webkitpy.w3c.wpt_github_mock import MockWPTGitHub |
| +def mock_command_exec(vals): |
| + def run_fn(args): |
| + if args[1] in vals: |
| + return vals[args[1]] |
| + else: |
| + return '' |
|
qyearsley
2016/12/16 00:45:17
Possible minor change:
def run_fn(args):
jeffcarp
2016/12/16 20:07:10
🙌🙌
|
| + return MockExecutive2(run_command_fn=run_fn) |
| + |
| + |
| class TestExporterTest(unittest.TestCase): |
| + def setUp(self): |
| + self.host = MockHost() |
| + self.wpt_github = MockWPTGitHub(pull_requests=[]) |
| + |
| def test_stops_if_more_than_one_pr_is_in_flight(self): |
| host = MockHost() |
| wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}]) |
| @@ -69,3 +83,58 @@ class TestExporterTest(unittest.TestCase): |
| 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')]) |
| + |
| + def test_exportable_commits_since(self): |
| + self.host.executive = mock_command_exec({ |
| + 'show': 'fake message', |
| + 'rev-list': 'badbeef8', |
| + 'rev-parse': 'badbeef8', |
| + 'crrev-parse': 'badbeef8', |
| + 'diff': 'fake diff', |
| + 'diff-tree': 'some\nfiles', |
| + 'format-patch': 'hey I\'m a patch', |
| + 'footers': 'cr-rev-position', |
| + }) |
| + test_exporter = TestExporter(self.host, self.wpt_github) |
| + |
| + commits = test_exporter.exportable_commits_since('beefcafe') |
| + self.assertEqual(len(commits), 1) |
| + self.assertIsInstance(commits[0], ChromiumCommit) |
|
qyearsley
2016/12/16 00:45:17
It would be helpful to assert what calls are made
jeffcarp
2016/12/16 20:07:10
Added. I think it makes the unit tests more brittl
|
| + |
| + def test_ignores_commits_with_noexport_true(self): |
| + self.host.executive = mock_command_exec({ |
| + 'show': 'Commit message\nNOEXPORT=true', |
| + 'rev-list': 'badbeef8', |
| + 'rev-parse': 'badbeef8', |
| + 'footers': 'cr-rev-position', |
| + }) |
| + test_exporter = TestExporter(self.host, self.wpt_github) |
| + |
| + commits = test_exporter.exportable_commits_since('beefcafe') |
| + self.assertEqual(len(commits), 0) |
| + |
| + def test_ignores_reverted_commits_with_noexport_true(self): |
| + self.host.executive = mock_command_exec({ |
| + 'show': 'Commit message\n> NOEXPORT=true', |
| + 'rev-list': 'badbeef8', |
| + 'rev-parse': 'badbeef8', |
| + 'footers': 'cr-rev-position', |
| + }) |
| + wpt_github = MockWPTGitHub(pull_requests=[]) |
| + test_exporter = TestExporter(self.host, wpt_github) |
| + |
| + commits = test_exporter.exportable_commits_since('beefcafe') |
| + self.assertEqual(len(commits), 0) |
| + |
| + def test_ignores_commits_that_start_with_import(self): |
| + self.host.executive = mock_command_exec({ |
| + 'show': 'Import rutabaga@deadbeef', |
| + 'rev-list': 'badbeef8', |
| + 'rev-parse': 'badbeef8', |
| + 'footers': 'cr-rev-position', |
| + }) |
| + wpt_github = MockWPTGitHub(pull_requests=[]) |
| + test_exporter = TestExporter(self.host, wpt_github) |
| + |
| + commits = test_exporter.exportable_commits_since('beefcafe') |
| + self.assertEqual(len(commits), 0) |