| 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 |
| 7 from webkitpy.common.host_mock import MockHost |
| 8 from webkitpy.common.system.executive_mock import MockExecutive |
| 9 from webkitpy.common.system.filesystem_mock import MockFileSystem |
| 6 from webkitpy.w3c.local_wpt import LocalWPT | 10 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 |
| 11 | 12 |
| 12 class LocalWPTTest(unittest.TestCase): | 13 class LocalWPTTest(unittest.TestCase): |
| 13 | 14 |
| 14 def test_fetches_if_wpt_exists(self): | 15 def test_fetches_if_wpt_exists(self): |
| 15 host = MockHost() | 16 host = MockHost() |
| 16 host.filesystem = MockFileSystem(files={ | 17 host.filesystem = MockFileSystem(files={ |
| 17 '/tmp/wpt': '' | 18 '/tmp/wpt': '' |
| 18 }) | 19 }) |
| 19 | 20 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 self.assertEqual(len(host.executive.calls), 2) | 53 self.assertEqual(len(host.executive.calls), 2) |
| 53 self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga']) | 54 self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga']) |
| 54 | 55 |
| 55 def test_last_wpt_exported_commit(self): | 56 def test_last_wpt_exported_commit(self): |
| 56 host = MockHost() | 57 host = MockHost() |
| 57 return_vals = [ | 58 return_vals = [ |
| 58 'deadbeefcafe', | 59 'deadbeefcafe', |
| 59 '123', | 60 '123', |
| 60 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', | 61 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', |
| 61 ] | 62 ] |
| 62 host.executive = MockExecutive2(run_command_fn=lambda _: return_vals.pop
()) | 63 host.executive = MockExecutive(run_command_fn=lambda _: return_vals.pop(
)) |
| 63 host.filesystem = MockFileSystem() | 64 host.filesystem = MockFileSystem() |
| 64 local_wpt = LocalWPT(host, no_fetch=True) | 65 local_wpt = LocalWPT(host, no_fetch=True) |
| 65 | 66 |
| 66 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit() | 67 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit() |
| 67 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8') | 68 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8') |
| 68 self.assertEqual(chromium_commit.position, '123') | 69 self.assertEqual(chromium_commit.position, '123') |
| 69 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') | 70 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') |
| 70 | 71 |
| 71 def test_last_wpt_exported_commit_not_found(self): | 72 def test_last_wpt_exported_commit_not_found(self): |
| 72 host = MockHost() | 73 host = MockHost() |
| 73 host.executive = MockExecutive2(run_command_fn=lambda _: None) | 74 host.executive = MockExecutive(run_command_fn=lambda _: None) |
| 74 host.filesystem = MockFileSystem() | 75 host.filesystem = MockFileSystem() |
| 75 local_wpt = LocalWPT(host) | 76 local_wpt = LocalWPT(host) |
| 76 | 77 |
| 77 commit = local_wpt.most_recent_chromium_commit() | 78 commit = local_wpt.most_recent_chromium_commit() |
| 78 self.assertEqual(commit, (None, None)) | 79 self.assertEqual(commit, (None, None)) |
| 79 | 80 |
| 80 def test_create_branch_with_patch(self): | 81 def test_create_branch_with_patch(self): |
| 81 host = MockHost() | 82 host = MockHost() |
| 82 host.filesystem = MockFileSystem() | 83 host.filesystem = MockFileSystem() |
| 83 | 84 |
| 84 local_wpt = LocalWPT(host) | 85 local_wpt = LocalWPT(host) |
| 85 | 86 |
| 86 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch
') | 87 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch
') |
| 87 self.assertEqual(len(host.executive.calls), 9) | 88 self.assertEqual(len(host.executive.calls), 9) |
| 88 self.assertEqual(local_branch_name, 'chromium-export-try') | 89 self.assertEqual(local_branch_name, 'chromium-export-try') |
| 89 # TODO(jeffcarp): Add more specific assertions | 90 # TODO(jeffcarp): Add more specific assertions |
| OLD | NEW |