Chromium Code Reviews| 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 unittest | 5 import unittest |
| 6 | 6 |
| 7 from webkitpy.common.host_mock import MockHost | 7 from webkitpy.common.host_mock import MockHost |
| 8 from webkitpy.common.system.executive_mock import MockExecutive2 | 8 from webkitpy.common.system.executive_mock import MockExecutive2 |
| 9 from webkitpy.w3c.chromium_commit import ChromiumCommit | 9 from webkitpy.w3c.chromium_commit import ChromiumCommit |
| 10 from webkitpy.w3c.test_exporter import TestExporter | 10 from webkitpy.w3c.test_exporter import TestExporter |
| 11 from webkitpy.w3c.wpt_github_mock import MockWPTGitHub | 11 from webkitpy.w3c.wpt_github_mock import MockWPTGitHub |
| 12 | 12 |
| 13 | 13 |
| 14 def mock_command_exec(vals): | 14 def mock_command_exec(vals): |
| 15 def run_fn(args): | 15 def run_fn(args): |
| 16 sub_command = args[1] | 16 sub_command = args[1] |
| 17 return vals.get(sub_command, '') | 17 return vals.get(sub_command, '') |
| 18 return MockExecutive2(run_command_fn=run_fn) | 18 return MockExecutive2(run_command_fn=run_fn) |
| 19 | 19 |
| 20 | 20 |
| 21 | |
| 22 class TestExporterTest(unittest.TestCase): | 21 class TestExporterTest(unittest.TestCase): |
| 23 | 22 |
| 24 def setUp(self): | 23 def setUp(self): |
| 25 self.host = MockHost() | 24 self.host = MockHost() |
| 26 self.wpt_github = MockWPTGitHub(pull_requests=[]) | 25 self.wpt_github = MockWPTGitHub(pull_requests=[]) |
| 27 | 26 |
| 28 def test_stops_if_more_than_one_pr_is_in_flight(self): | 27 def test_stops_if_more_than_one_pr_is_in_flight(self): |
| 29 host = MockHost() | 28 host = MockHost() |
| 30 wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}]) | 29 wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}]) |
| 31 | 30 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 git_command = args[1] | 63 git_command = args[1] |
| 65 if git_command == 'rev-list': | 64 if git_command == 'rev-list': |
| 66 return 'facebeef\ncafedad5' | 65 return 'facebeef\ncafedad5' |
| 67 elif git_command == 'footers': | 66 elif git_command == 'footers': |
| 68 return 'fake-cr-position' | 67 return 'fake-cr-position' |
| 69 elif git_command == 'show': | 68 elif git_command == 'show': |
| 70 if 'cafedad5' in args: | 69 if 'cafedad5' in args: |
| 71 return 'newer fake text' | 70 return 'newer fake text' |
| 72 elif 'facebeef' in args: | 71 elif 'facebeef' in args: |
| 73 return 'older fake text' | 72 return 'older fake text' |
| 73 elif git_command == 'remote': | |
| 74 return 'github' | |
| 75 elif git_command == 'format-patch': | |
| 76 return 'fake patch' | |
| 77 elif git_command == 'diff': | |
| 78 return 'fake patch diff' | |
| 79 elif git_command == 'diff-tree': | |
| 80 return 'fake\nfiles\nchanged' | |
| 74 else: | 81 else: |
| 75 return '' | 82 return '' |
|
qyearsley
2016/12/22 22:04:54
This is definitely fine, although doing something
| |
| 76 | 83 |
| 77 host.executive = MockExecutive2(run_command_fn=mock_command) | 84 host.executive = MockExecutive2(run_command_fn=mock_command) |
| 78 wpt_github = MockWPTGitHub(pull_requests=[]) | 85 wpt_github = MockWPTGitHub(pull_requests=[]) |
| 79 | 86 |
| 80 TestExporter(host, wpt_github).run() | 87 TestExporter(host, wpt_github).run() |
| 81 | 88 |
| 82 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_p r']) | 89 self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_p r']) |
| 83 self.assertEqual(wpt_github.pull_requests_created, | 90 self.assertEqual(wpt_github.pull_requests_created, |
| 84 [('chromium-export-try', 'older fake text', 'older fake text')]) | 91 [('chromium-export-try', 'older fake text', 'older fake text')]) |
| 85 | 92 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 }) | 154 }) |
| 148 wpt_github = MockWPTGitHub(pull_requests=[]) | 155 wpt_github = MockWPTGitHub(pull_requests=[]) |
| 149 test_exporter = TestExporter(self.host, wpt_github) | 156 test_exporter = TestExporter(self.host, wpt_github) |
| 150 | 157 |
| 151 commits = test_exporter.exportable_commits_since('beefcafe') | 158 commits = test_exporter.exportable_commits_since('beefcafe') |
| 152 self.assertEqual(len(commits), 0) | 159 self.assertEqual(len(commits), 0) |
| 153 self.assertEqual(self.host.executive.calls, [ | 160 self.assertEqual(self.host.executive.calls, [ |
| 154 ['git', 'rev-parse', '--show-toplevel'], | 161 ['git', 'rev-parse', '--show-toplevel'], |
| 155 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'], | 162 ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/t hird_party/WebKit/LayoutTests/imported/wpt/'], |
| 156 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']]) | 163 ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']]) |
| OLD | NEW |