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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/git_unittest.py

Issue 2815093005: Clean up webkitpy.common.checkout.git module. (Closed)
Patch Set: git co wpt-import Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/git.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.system.executive import Executive, ScriptError 7 from webkitpy.common.system.executive import Executive, ScriptError
8 from webkitpy.common.system.executive_mock import MockExecutive 8 from webkitpy.common.system.executive_mock import MockExecutive
9 from webkitpy.common.system.filesystem import FileSystem 9 from webkitpy.common.system.filesystem import FileSystem
10 from webkitpy.common.system.filesystem_mock import MockFileSystem 10 from webkitpy.common.system.filesystem_mock import MockFileSystem
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 class GitTestWithMock(unittest.TestCase): 191 class GitTestWithMock(unittest.TestCase):
192 192
193 def make_git(self): 193 def make_git(self):
194 git = Git(cwd='.', executive=MockExecutive(), filesystem=MockFileSystem( )) 194 git = Git(cwd='.', executive=MockExecutive(), filesystem=MockFileSystem( ))
195 git.read_git_config = lambda *args, **kw: 'MOCKKEY:MOCKVALUE' 195 git.read_git_config = lambda *args, **kw: 'MOCKKEY:MOCKVALUE'
196 return git 196 return git
197 197
198 def _assert_timestamp_of_revision(self, canned_git_output, expected): 198 def _assert_timestamp_of_revision(self, canned_git_output, expected):
199 git = self.make_git() 199 git = self.make_git()
200 git.find_checkout_root = lambda path: '' 200 git.find_checkout_root = lambda path: ''
201 # Modifying protected method. pylint: disable=protected-access 201 git.run = lambda args: canned_git_output
202 git._run_git = lambda args: canned_git_output
203 self.assertEqual(git.timestamp_of_revision('some-path', '12345'), expect ed) 202 self.assertEqual(git.timestamp_of_revision('some-path', '12345'), expect ed)
204 203
205 def test_timestamp_of_revision_utc(self): 204 def test_timestamp_of_revision_utc(self):
206 self._assert_timestamp_of_revision('Date: 2013-02-08 08:05:49 +0000', '2 013-02-08T08:05:49Z') 205 self._assert_timestamp_of_revision('Date: 2013-02-08 08:05:49 +0000', '2 013-02-08T08:05:49Z')
207 206
208 def test_timestamp_of_revision_positive_timezone(self): 207 def test_timestamp_of_revision_positive_timezone(self):
209 self._assert_timestamp_of_revision('Date: 2013-02-08 01:02:03 +0130', '2 013-02-07T23:32:03Z') 208 self._assert_timestamp_of_revision('Date: 2013-02-08 01:02:03 +0130', '2 013-02-07T23:32:03Z')
210 209
211 def test_timestamp_of_revision_pacific_timezone(self): 210 def test_timestamp_of_revision_pacific_timezone(self):
212 self._assert_timestamp_of_revision('Date: 2013-02-08 01:55:21 -0800', '2 013-02-08T09:55:21Z') 211 self._assert_timestamp_of_revision('Date: 2013-02-08 01:55:21 -0800', '2 013-02-08T09:55:21Z')
213 212
214 def test_unstaged_files(self): 213 def test_unstaged_files(self):
215 git = self.make_git() 214 git = self.make_git()
216 status_lines = [ 215 status_lines = [
217 ' M d/modified.txt', 216 ' M d/modified.txt',
218 ' D d/deleted.txt', 217 ' D d/deleted.txt',
219 '?? d/untracked.txt', 218 '?? d/untracked.txt',
220 '?? a', 219 '?? a',
221 'D d/deleted.txt', 220 'D d/deleted.txt',
222 'M d/modified-staged.txt', 221 'M d/modified-staged.txt',
223 'A d/added-staged.txt', 222 'A d/added-staged.txt',
224 ] 223 ]
225 # pylint: disable=protected-access 224 git.run = lambda args: '\x00'.join(status_lines) + '\x00'
226 git._run_git = lambda args: '\x00'.join(status_lines) + '\x00'
227 self.assertEqual( 225 self.assertEqual(
228 git.unstaged_changes(), 226 git.unstaged_changes(),
229 { 227 {
230 'd/modified.txt': 'M', 228 'd/modified.txt': 'M',
231 'd/deleted.txt': 'D', 229 'd/deleted.txt': 'D',
232 'd/untracked.txt': '?', 230 'd/untracked.txt': '?',
233 'a': '?', 231 'a': '?',
234 }) 232 })
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/git.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698