Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py

Issue 2719173002: [WPT Export] Require GitHub API token in WPT remote origin URL (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 MockExecutive, mock_git_comman ds 8 from webkitpy.common.system.executive_mock import MockExecutive, mock_git_comman ds
9 from webkitpy.common.system.filesystem_mock import MockFileSystem 9 from webkitpy.common.system.filesystem_mock import MockFileSystem
10 from webkitpy.w3c.local_wpt import LocalWPT 10 from webkitpy.w3c.local_wpt import LocalWPT
11 11
12 12
13 class LocalWPTTest(unittest.TestCase): 13 class LocalWPTTest(unittest.TestCase):
14 14
15 def test_fetch_when_wpt_dir_exists(self): 15 def test_fetch_when_wpt_dir_exists(self):
16 host = MockHost() 16 host = MockHost()
17 host.filesystem = MockFileSystem(files={ 17 host.filesystem = MockFileSystem(files={
18 '/tmp/wpt': '' 18 '/tmp/wpt': ''
19 }) 19 })
20 20
21 local_wpt = LocalWPT(host) 21 local_wpt = LocalWPT(host, 'token')
22 local_wpt.fetch() 22 local_wpt.fetch()
23 23
24 self.assertEqual(host.executive.calls, [ 24 self.assertEqual(host.executive.calls, [
25 ['git', 'fetch', 'origin'], 25 ['git', 'fetch', 'origin'],
26 ['git', 'checkout', 'origin/master'], 26 ['git', 'checkout', 'origin/master'],
27 ]) 27 ])
28 28
29 def test_fetch_when_wpt_dir_does_not_exist(self): 29 def test_fetch_when_wpt_dir_does_not_exist(self):
30 host = MockHost() 30 host = MockHost()
31 host.filesystem = MockFileSystem() 31 host.filesystem = MockFileSystem()
32 32
33 local_wpt = LocalWPT(host) 33 local_wpt = LocalWPT(host, 'token')
34 local_wpt.fetch() 34 local_wpt.fetch()
35 35
36 self.assertEqual(host.executive.calls, [ 36 self.assertEqual(host.executive.calls, [
37 ['git', 'clone', 'https://github.com/w3c/web-platform-tests.git', '/ tmp/wpt'], 37 ['git', 'clone', 'https://token@github.com/w3c/web-platform-tests.gi t', '/tmp/wpt'],
38 ]) 38 ])
39 39
40 def test_constructor(self): 40 def test_constructor(self):
41 host = MockHost() 41 host = MockHost()
42 LocalWPT(host) 42 LocalWPT(host, 'token')
43 self.assertEqual(len(host.executive.calls), 0) 43 self.assertEqual(len(host.executive.calls), 0)
44 44
45 def test_run(self): 45 def test_run(self):
46 host = MockHost() 46 host = MockHost()
47 host.filesystem = MockFileSystem() 47 host.filesystem = MockFileSystem()
48 local_wpt = LocalWPT(host) 48 local_wpt = LocalWPT(host, 'token')
49 local_wpt.run(['echo', 'rutabaga']) 49 local_wpt.run(['echo', 'rutabaga'])
50 self.assertEqual(host.executive.calls, [['echo', 'rutabaga']]) 50 self.assertEqual(host.executive.calls, [['echo', 'rutabaga']])
51 51
52 def test_last_wpt_exported_commit(self): 52 def test_last_wpt_exported_commit(self):
53 host = MockHost() 53 host = MockHost()
54 host.executive = mock_git_commands({ 54 host.executive = mock_git_commands({
55 'rev-list': '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', 55 'rev-list': '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
56 'footers': 'Cr-Commit-Position: 123', 56 'footers': 'Cr-Commit-Position: 123',
57 'crrev-parse': 'add087a97844f4b9e307d9a216940582d96db306', 57 'crrev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
58 }, strict=True) 58 }, strict=True)
59 host.filesystem = MockFileSystem() 59 host.filesystem = MockFileSystem()
60 local_wpt = LocalWPT(host) 60 local_wpt = LocalWPT(host, 'token')
61 61
62 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit() 62 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit()
63 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8') 63 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8')
64 self.assertEqual(chromium_commit.position, '123') 64 self.assertEqual(chromium_commit.position, '123')
65 self.assertEqual(chromium_commit.sha, 'add087a97844f4b9e307d9a216940582d 96db306') 65 self.assertEqual(chromium_commit.sha, 'add087a97844f4b9e307d9a216940582d 96db306')
66 66
67 def test_last_wpt_exported_commit_not_found(self): 67 def test_last_wpt_exported_commit_not_found(self):
68 host = MockHost() 68 host = MockHost()
69 host.executive = MockExecutive(run_command_fn=lambda _: '') 69 host.executive = MockExecutive(run_command_fn=lambda _: '')
70 host.filesystem = MockFileSystem() 70 host.filesystem = MockFileSystem()
71 local_wpt = LocalWPT(host) 71 local_wpt = LocalWPT(host, 'token')
72 72
73 commit = local_wpt.most_recent_chromium_commit() 73 commit = local_wpt.most_recent_chromium_commit()
74 self.assertEqual(commit, (None, None)) 74 self.assertEqual(commit, (None, None))
75 75
76 def test_create_branch_with_patch(self): 76 def test_create_branch_with_patch(self):
77 host = MockHost() 77 host = MockHost()
78 host.filesystem = MockFileSystem() 78 host.filesystem = MockFileSystem()
79 79
80 local_wpt = LocalWPT(host) 80 local_wpt = LocalWPT(host, 'token')
81 local_wpt.fetch() 81 local_wpt.fetch()
82 82
83 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch ', 'author') 83 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch ', 'author')
84 self.assertEqual(local_branch_name, 'chromium-export-try') 84 self.assertEqual(local_branch_name, 'chromium-export-try')
85 self.assertEqual(host.executive.calls, [ 85 self.assertEqual(host.executive.calls, [
86 ['git', 'clone', 'https://github.com/w3c/web-platform-tests.git', '/ tmp/wpt'], 86 ['git', 'clone', '--depth=10', 'https://token@github.com/w3c/web-pla tform-tests.git', '/tmp/wpt'],
87 ['git', 'reset', '--hard', 'HEAD'], 87 ['git', 'reset', '--hard', 'HEAD'],
88 ['git', 'clean', '-fdx'], 88 ['git', 'clean', '-fdx'],
89 ['git', 'checkout', 'origin/master'], 89 ['git', 'checkout', 'origin/master'],
90 ['git', 'branch', '-a'], 90 ['git', 'branch', '-a'],
91 ['git', 'branch', '-a'], 91 ['git', 'branch', '-a'],
92 ['git', 'checkout', '-b', 'chromium-export-try'], 92 ['git', 'checkout', '-b', 'chromium-export-try'],
93 ['git', 'apply', '-'], 93 ['git', 'apply', '-'],
94 ['git', 'add', '.'], 94 ['git', 'add', '.'],
95 ['git', 'commit', '--author', 'author', '-am', 'message'], 95 ['git', 'commit', '--author', 'author', '-am', 'message'],
96 ['git', 'push', '-f', 'origin', 'chromium-export-try']]) 96 ['git', 'push', '-f', 'origin', 'chromium-export-try']])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698