| 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.filesystem = MockFileSystem(files={ |
| 17 '/tmp/wpt': '' |
| 18 }) |
| 19 |
| 20 LocalWPT(host) |
| 21 |
| 22 self.assertEqual(len(host.executive.calls), 3) |
| 23 self.assertEqual(host.executive.calls[0][1], 'checkout') |
| 24 self.assertEqual(host.executive.calls[1][1], 'fetch') |
| 25 self.assertEqual(host.executive.calls[2][1], 'merge') |
| 26 |
| 27 def test_clones_if_wpt_does_not_exist(self): |
| 28 host = MockHost() |
| 29 host.filesystem = MockFileSystem() |
| 30 |
| 31 LocalWPT(host) |
| 32 |
| 33 self.assertEqual(len(host.executive.calls), 1) |
| 34 self.assertEqual(host.executive.calls[0][1], 'clone') |
| 35 |
| 36 def test_no_fetch_flag(self): |
| 37 host = MockHost() |
| 38 host.filesystem = MockFileSystem(files={ |
| 39 '/tmp/wpt': '' |
| 40 }) |
| 41 |
| 42 LocalWPT(host, no_fetch=True) |
| 43 |
| 44 self.assertEqual(len(host.executive.calls), 0) |
| 45 |
| 46 def test_run(self): |
| 47 host = MockHost() |
| 48 host.filesystem = MockFileSystem() |
| 49 |
| 50 local_wpt = LocalWPT(host) |
| 51 |
| 52 local_wpt.run(['echo', 'rutabaga']) |
| 53 self.assertEqual(len(host.executive.calls), 2) |
| 54 self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga']) |
| 55 |
| 56 def test_last_wpt_exported_commit(self): |
| 57 host = MockHost() |
| 58 return_vals = [ |
| 59 '123', |
| 60 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', |
| 61 ] |
| 62 host.executive = MockExecutive2(run_command_fn=lambda _: return_vals.pop
()) |
| 63 host.filesystem = MockFileSystem() |
| 64 local_wpt = LocalWPT(host, no_fetch=True) |
| 65 |
| 66 commit = local_wpt.most_recent_chromium_commit() |
| 67 self.assertEqual(commit, ('9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', '1
23')) |
| 68 |
| 69 def test_last_wpt_exported_commit_not_found(self): |
| 70 host = MockHost() |
| 71 host.executive = MockExecutive2(run_command_fn=lambda _: None) |
| 72 host.filesystem = MockFileSystem() |
| 73 local_wpt = LocalWPT(host) |
| 74 |
| 75 commit = local_wpt.most_recent_chromium_commit() |
| 76 self.assertEqual(commit, (None, None)) |
| 77 |
| 78 def test_create_branch_with_patch(self): |
| 79 host = MockHost() |
| 80 host.filesystem = MockFileSystem() |
| 81 |
| 82 local_wpt = LocalWPT(host) |
| 83 |
| 84 local_wpt.create_branch_with_patch('branch-name', 'message', 'patch') |
| 85 self.assertEqual(len(host.executive.calls), 9) |
| 86 # TODO(jeffcarp): Add more specific assertions |
| OLD | NEW |