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

Side by Side Diff: tests/gcl_unittest.py

Issue 399009: Reapply 32057, 32058, 32059, 32062 and fixes problems introduced by these changes. (Closed)
Patch Set: Created 11 years, 1 month 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 | « scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for gcl.py.""" 6 """Unit tests for gcl.py."""
7 7
8 # Local imports 8 # Local imports
9 import gcl 9 import gcl
10 from super_mox import mox, SuperMoxTestBase 10 from super_mox import mox, SuperMoxTestBase
11 11
12 12
13 class GclTestsBase(SuperMoxTestBase): 13 class GclTestsBase(SuperMoxTestBase):
14 """Setups and tear downs the mocks but doesn't test anything as-is.""" 14 """Setups and tear downs the mocks but doesn't test anything as-is."""
15 def setUp(self): 15 def setUp(self):
16 SuperMoxTestBase.setUp(self) 16 SuperMoxTestBase.setUp(self)
17 self.fake_root_dir = self.RootDir() 17 self.fake_root_dir = self.RootDir()
18 self.mox.StubOutWithMock(gcl, 'RunShell') 18 self.mox.StubOutWithMock(gcl, 'RunShell')
19 self.mox.StubOutWithMock(gcl.gclient_scm, 'CaptureSVNInfo') 19 self.mox.StubOutWithMock(gcl.SVN, 'CaptureInfo')
20 self.mox.StubOutWithMock(gcl, 'tempfile') 20 self.mox.StubOutWithMock(gcl, 'tempfile')
21 self.mox.StubOutWithMock(gcl.upload, 'RealMain') 21 self.mox.StubOutWithMock(gcl.upload, 'RealMain')
22 # These are not tested. 22 # These are not tested.
23 self.mox.StubOutWithMock(gcl, 'ReadFile') 23 self.mox.StubOutWithMock(gcl, 'ReadFile')
24 self.mox.StubOutWithMock(gcl, 'WriteFile') 24 self.mox.StubOutWithMock(gcl, 'WriteFile')
25 25
26 26
27 class GclUnittest(GclTestsBase): 27 class GclUnittest(GclTestsBase):
28 """General gcl.py tests.""" 28 """General gcl.py tests."""
29 def testMembersChanged(self): 29 def testMembersChanged(self):
30 self.mox.ReplayAll() 30 self.mox.ReplayAll()
31 members = [ 31 members = [
32 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 32 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'Change',
33 'Change', 'ChangeInfo', 'Changes', 'Commit', 33 'ChangeInfo', 'Changes', 'Commit', 'DEFAULT_LINT_IGNORE_REGEX',
34 'DEFAULT_LINT_IGNORE_REGEX', 'DEFAULT_LINT_REGEX', 34 'DEFAULT_LINT_REGEX', 'DeleteEmptyChangeLists', 'DoPresubmitChecks',
35 'DeleteEmptyChangeLists', 'DoPresubmitChecks', 35 'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName',
36 'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName', 36 'GenerateDiff', 'GetCLs', 'GetCacheDir', 'GetCachedFile',
37 'GenerateDiff', 37 'GetChangelistInfoFile', 'GetChangesDir', 'GetCodeReviewSetting',
38 'GetCacheDir', 'GetCachedFile', 'GetChangesDir', 'GetCLs', 38 'GetEditor', 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription',
39 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor', 39 'GetModifiedFiles', 'GetRepositoryRoot', 'Help', 'Lint',
40 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', 40 'LoadChangelistInfoForMultiple', 'MISSING_TEST_MSG', 'Opened',
41 'GetModifiedFiles', 'GetRepositoryRoot', 41 'OptionallyDoPresubmitChecks', 'PresubmitCL', 'REPOSITORY_ROOT',
42 'GetSVNFileProperty', 'Help', 'IsSVNMoved', 42 'ReadFile', 'RunShell', 'RunShellWithReturnCode', 'SVN',
43 'Lint', 'LoadChangelistInfoForMultiple', 43 'SendToRietveld', 'TryChange', 'UnknownFiles', 'UploadCL', 'Warn',
44 'MISSING_TEST_MSG', 'Opened', 'OptionallyDoPresubmitChecks', 44 'WriteFile', 'gclient_utils', 'getpass', 'main', 'os', 'random', 're',
45 'PresubmitCL', 'ReadFile', 'REPOSITORY_ROOT', 'RunShell', 45 'shutil', 'string', 'subprocess', 'sys', 'tempfile', 'upload',
46 'RunShellWithReturnCode', 'SendToRietveld', 'TryChange', 46 'urllib2',
47 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile',
48 'gclient_scm', 'gclient_utils', 'getpass', 'main', 'os', 'random', 're',
49 'shutil', 'string', 'subprocess', 'sys', 'tempfile',
50 'upload', 'urllib2',
51 ] 47 ]
52 # If this test fails, you should add the relevant test. 48 # If this test fails, you should add the relevant test.
53 self.compareMembers(gcl, members) 49 self.compareMembers(gcl, members)
54 50
55 def testIsSVNMoved(self): 51 def testIsSVNMoved(self):
56 # TODO(maruel): TEST ME 52 # TODO(maruel): TEST ME
57 pass 53 pass
58 54
59 def testGetSVNFileProperty(self): 55 def testGetSVNFileProperty(self):
60 # TODO(maruel): TEST ME 56 # TODO(maruel): TEST ME
61 pass 57 pass
62 58
63 def testUnknownFiles(self): 59 def testUnknownFiles(self):
64 # TODO(maruel): TEST ME 60 # TODO(maruel): TEST ME
65 pass 61 pass
66 62
67 def testGetRepositoryRootNone(self): 63 def testGetRepositoryRootNone(self):
68 gcl.REPOSITORY_ROOT = None 64 gcl.REPOSITORY_ROOT = None
69 gcl.os.getcwd().AndReturn("/bleh/prout") 65 gcl.os.getcwd().AndReturn("/bleh/prout")
70 result = { 66 result = {
71 "Repository Root": "" 67 "Repository Root": ""
72 } 68 }
73 gcl.gclient_scm.CaptureSVNInfo("/bleh/prout", print_error=False).AndReturn( 69 gcl.SVN.CaptureInfo("/bleh/prout", print_error=False).AndReturn(result)
74 result)
75 self.mox.ReplayAll() 70 self.mox.ReplayAll()
76 self.assertRaises(Exception, gcl.GetRepositoryRoot) 71 self.assertRaises(Exception, gcl.GetRepositoryRoot)
77 72
78 def testGetRepositoryRootGood(self): 73 def testGetRepositoryRootGood(self):
79 gcl.REPOSITORY_ROOT = None 74 gcl.REPOSITORY_ROOT = None
80 root_path = gcl.os.path.join('bleh', 'prout', 'pouet') 75 root_path = gcl.os.path.join('bleh', 'prout', 'pouet')
81 gcl.os.getcwd().AndReturn(root_path) 76 gcl.os.getcwd().AndReturn(root_path)
82 result1 = { "Repository Root": "Some root" } 77 result1 = { "Repository Root": "Some root" }
83 gcl.gclient_scm.CaptureSVNInfo(root_path, 78 gcl.SVN.CaptureInfo(root_path, print_error=False).AndReturn(result1)
84 print_error=False).AndReturn(result1)
85 gcl.os.getcwd().AndReturn(root_path) 79 gcl.os.getcwd().AndReturn(root_path)
86 results2 = { "Repository Root": "A different root" } 80 results2 = { "Repository Root": "A different root" }
87 gcl.gclient_scm.CaptureSVNInfo( 81 gcl.SVN.CaptureInfo(gcl.os.path.dirname(root_path),
88 gcl.os.path.dirname(root_path), 82 print_error=False).AndReturn(results2)
89 print_error=False).AndReturn(results2)
90 self.mox.ReplayAll() 83 self.mox.ReplayAll()
91 self.assertEquals(gcl.GetRepositoryRoot(), root_path) 84 self.assertEquals(gcl.GetRepositoryRoot(), root_path)
92 85
93 def testGetCachedFile(self): 86 def testGetCachedFile(self):
94 # TODO(maruel): TEST ME 87 # TODO(maruel): TEST ME
95 pass 88 pass
96 89
97 def testGetCodeReviewSetting(self): 90 def testGetCodeReviewSetting(self):
98 # TODO(maruel): TEST ME 91 # TODO(maruel): TEST ME
99 pass 92 pass
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 self.mox.ReplayAll() 340 self.mox.ReplayAll()
348 341
349 gcl.UploadCL(change_info, args) 342 gcl.UploadCL(change_info, args)
350 self.assertEquals(change_info.issue, 1) 343 self.assertEquals(change_info.issue, 1)
351 self.assertEquals(change_info.patchset, 2) 344 self.assertEquals(change_info.patchset, 2)
352 345
353 346
354 if __name__ == '__main__': 347 if __name__ == '__main__':
355 import unittest 348 import unittest
356 unittest.main() 349 unittest.main()
OLDNEW
« no previous file with comments | « scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698