Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 from webkitpy.w3c.local_wpt import LocalWPT | |
| 7 from webkitpy.common.host_mock import MockHost | |
| 8 from webkitpy.common.system.executive_mock import MockExecutive2 | |
| 9 from webkitpy.common.system.filesystem_mock import MockFileSystem | |
| 10 | |
| 11 | |
| 12 class LocalWPTTest(unittest.TestCase): | |
| 13 | |
| 14 def test_fetches_if_wpt_exists(self): | |
| 15 host = MockHost() | |
| 16 host.executive = MockExecutive2() | |
|
qyearsley
2016/11/01 22:57:45
If nothing special is done here, then I think the
| |
| 17 host.filesystem = MockFileSystem(files={ | |
| 18 '/tmp/wpt': '' | |
| 19 }) | |
| 20 | |
| 21 LocalWPT(host) | |
| 22 | |
| 23 self.assertEqual(len(host.executive.calls), 3) | |
| 24 self.assertEqual(host.executive.calls[0][1], 'checkout') | |
|
foolip
2016/11/01 22:07:45
Neat test!
| |
| 25 self.assertEqual(host.executive.calls[1][1], 'fetch') | |
| 26 self.assertEqual(host.executive.calls[2][1], 'merge') | |
| 27 | |
| 28 def test_clones_if_wpt_does_not_exist(self): | |
| 29 host = MockHost() | |
| 30 host.executive = MockExecutive2() | |
| 31 host.filesystem = MockFileSystem() | |
| 32 | |
| 33 LocalWPT(host) | |
| 34 | |
| 35 self.assertEqual(len(host.executive.calls), 1) | |
| 36 self.assertEqual(host.executive.calls[0][1], 'clone') | |
| 37 | |
| 38 def test_no_fetch_flag(self): | |
| 39 host = MockHost() | |
| 40 host.executive = MockExecutive2() | |
| 41 host.filesystem = MockFileSystem(files={ | |
| 42 '/tmp/wpt': '' | |
| 43 }) | |
| 44 | |
| 45 LocalWPT(host, no_fetch=True) | |
| 46 | |
| 47 self.assertEqual(len(host.executive.calls), 0) | |
| 48 | |
| 49 def test_run(self): | |
| 50 host = MockHost() | |
| 51 host.executive = MockExecutive2() | |
| 52 host.filesystem = MockFileSystem() | |
| 53 | |
| 54 local_wpt = LocalWPT(host) | |
| 55 | |
| 56 local_wpt.run(['echo', 'rutabaga']) | |
| 57 self.assertEqual(len(host.executive.calls), 2) | |
| 58 self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga']) | |
| 59 | |
| 60 def test_last_wpt_exported_commit(self): | |
| 61 host = MockHost() | |
| 62 return_vals = [ | |
| 63 'Test commit message\nCr-Commit-Position: 123', | |
| 64 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', | |
| 65 ] | |
| 66 host.executive = MockExecutive2(run_command_fn=lambda _: return_vals.pop ()) | |
| 67 host.filesystem = MockFileSystem() | |
| 68 local_wpt = LocalWPT(host, no_fetch=True) | |
| 69 | |
| 70 commit = local_wpt.most_recent_cr_commit() | |
| 71 self.assertEqual(commit, ('9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', '1 23')) | |
| 72 | |
| 73 def test_last_wpt_exported_commit_not_found(self): | |
| 74 host = MockHost() | |
| 75 host.executive = MockExecutive2(run_command_fn=lambda _: None) | |
| 76 host.filesystem = MockFileSystem() | |
| 77 local_wpt = LocalWPT(host) | |
| 78 | |
| 79 commit = local_wpt.most_recent_cr_commit() | |
| 80 self.assertEqual(commit, (None, None)) | |
| 81 | |
| 82 def test_create_local_branch_with_patch(self): | |
| 83 host = MockHost() | |
| 84 host.executive = MockExecutive2() | |
| 85 host.filesystem = MockFileSystem() | |
| 86 | |
| 87 local_wpt = LocalWPT(host) | |
| 88 | |
| 89 local_wpt.create_branch_with_patch('branch-name', 'message', 'patch') | |
| 90 self.assertEqual(len(host.executive.calls), 8) | |
|
foolip
2016/11/01 22:07:45
Should this assert anything about what the calls a
jeffcarp
2016/11/01 23:21:18
The method was still in flux so I didn't write any
| |
| OLD | NEW |