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

Side by Side Diff: tests/gcl_unittest.py

Issue 391075: Revert 32057, 32058, 32059, 32062 because they still have unwanted side-effects. (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.SVN, 'CaptureInfo') 19 self.mox.StubOutWithMock(gcl.gclient_scm, 'CaptureSVNInfo')
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', 'Change', 32 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE',
33 'ChangeInfo', 'Changes', 'Commit', 'DEFAULT_LINT_IGNORE_REGEX', 33 'Change', 'ChangeInfo', 'Changes', 'Commit',
34 'DEFAULT_LINT_REGEX', 'DeleteEmptyChangeLists', 'DoPresubmitChecks', 34 'DEFAULT_LINT_IGNORE_REGEX', 'DEFAULT_LINT_REGEX',
35 'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName', 35 'DeleteEmptyChangeLists', 'DoPresubmitChecks',
36 'GenerateDiff', 'GetCLs', 'GetCacheDir', 'GetCachedFile', 36 'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName',
37 'GetChangelistInfoFile', 'GetChangesDir', 'GetCodeReviewSetting', 37 'GenerateDiff',
38 'GetEditor', 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', 38 'GetCacheDir', 'GetCachedFile', 'GetChangesDir', 'GetCLs',
39 'GetModifiedFiles', 'GetRepositoryRoot', 'Help', 'Lint', 39 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor',
40 'LoadChangelistInfoForMultiple', 'MISSING_TEST_MSG', 'Opened', 40 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription',
41 'OptionallyDoPresubmitChecks', 'PresubmitCL', 'REPOSITORY_ROOT', 41 'GetModifiedFiles', 'GetRepositoryRoot',
42 'ReadFile', 'RunShell', 'RunShellWithReturnCode', 'SVN', 42 'GetSVNFileProperty', 'Help', 'IsSVNMoved',
43 'SendToRietveld', 'TryChange', 'UnknownFiles', 'UploadCL', 'Warn', 43 'Lint', 'LoadChangelistInfoForMultiple',
44 'WriteFile', 'gclient_utils', 'getpass', 'main', 'os', 'random', 're', 44 'MISSING_TEST_MSG', 'Opened', 'OptionallyDoPresubmitChecks',
45 'shutil', 'string', 'subprocess', 'sys', 'tempfile', 'upload', 45 'PresubmitCL', 'ReadFile', 'REPOSITORY_ROOT', 'RunShell',
46 'urllib2', 46 'RunShellWithReturnCode', 'SendToRietveld', 'TryChange',
47 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile',
48 'gclient_scm', 'gclient_utils', 'getpass', 'main', 'os', 'random', 're',
49 'shutil', 'string', 'subprocess', 'sys', 'tempfile',
50 'upload', 'urllib2',
47 ] 51 ]
48 # If this test fails, you should add the relevant test. 52 # If this test fails, you should add the relevant test.
49 self.compareMembers(gcl, members) 53 self.compareMembers(gcl, members)
50 54
51 def testIsSVNMoved(self): 55 def testIsSVNMoved(self):
52 # TODO(maruel): TEST ME 56 # TODO(maruel): TEST ME
53 pass 57 pass
54 58
55 def testGetSVNFileProperty(self): 59 def testGetSVNFileProperty(self):
56 # TODO(maruel): TEST ME 60 # TODO(maruel): TEST ME
57 pass 61 pass
58 62
59 def testUnknownFiles(self): 63 def testUnknownFiles(self):
60 # TODO(maruel): TEST ME 64 # TODO(maruel): TEST ME
61 pass 65 pass
62 66
63 def testGetRepositoryRootNone(self): 67 def testGetRepositoryRootNone(self):
64 gcl.REPOSITORY_ROOT = None 68 gcl.REPOSITORY_ROOT = None
65 gcl.os.getcwd().AndReturn("/bleh/prout") 69 gcl.os.getcwd().AndReturn("/bleh/prout")
66 result = { 70 result = {
67 "Repository Root": "" 71 "Repository Root": ""
68 } 72 }
69 gcl.SVN.CaptureInfo("/bleh/prout", print_error=False).AndReturn(result) 73 gcl.gclient_scm.CaptureSVNInfo("/bleh/prout", print_error=False).AndReturn(
74 result)
70 self.mox.ReplayAll() 75 self.mox.ReplayAll()
71 self.assertRaises(Exception, gcl.GetRepositoryRoot) 76 self.assertRaises(Exception, gcl.GetRepositoryRoot)
72 77
73 def testGetRepositoryRootGood(self): 78 def testGetRepositoryRootGood(self):
74 gcl.REPOSITORY_ROOT = None 79 gcl.REPOSITORY_ROOT = None
75 root_path = gcl.os.path.join('bleh', 'prout', 'pouet') 80 root_path = gcl.os.path.join('bleh', 'prout', 'pouet')
76 gcl.os.getcwd().AndReturn(root_path) 81 gcl.os.getcwd().AndReturn(root_path)
77 result1 = { "Repository Root": "Some root" } 82 result1 = { "Repository Root": "Some root" }
78 gcl.SVN.CaptureInfo(root_path, print_error=False).AndReturn(result1) 83 gcl.gclient_scm.CaptureSVNInfo(root_path,
84 print_error=False).AndReturn(result1)
79 gcl.os.getcwd().AndReturn(root_path) 85 gcl.os.getcwd().AndReturn(root_path)
80 results2 = { "Repository Root": "A different root" } 86 results2 = { "Repository Root": "A different root" }
81 gcl.SVN.CaptureInfo(gcl.os.path.dirname(root_path), 87 gcl.gclient_scm.CaptureSVNInfo(
82 print_error=False).AndReturn(results2) 88 gcl.os.path.dirname(root_path),
89 print_error=False).AndReturn(results2)
83 self.mox.ReplayAll() 90 self.mox.ReplayAll()
84 self.assertEquals(gcl.GetRepositoryRoot(), root_path) 91 self.assertEquals(gcl.GetRepositoryRoot(), root_path)
85 92
86 def testGetCachedFile(self): 93 def testGetCachedFile(self):
87 # TODO(maruel): TEST ME 94 # TODO(maruel): TEST ME
88 pass 95 pass
89 96
90 def testGetCodeReviewSetting(self): 97 def testGetCodeReviewSetting(self):
91 # TODO(maruel): TEST ME 98 # TODO(maruel): TEST ME
92 pass 99 pass
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 self.mox.ReplayAll() 347 self.mox.ReplayAll()
341 348
342 gcl.UploadCL(change_info, args) 349 gcl.UploadCL(change_info, args)
343 self.assertEquals(change_info.issue, 1) 350 self.assertEquals(change_info.issue, 1)
344 self.assertEquals(change_info.patchset, 2) 351 self.assertEquals(change_info.patchset, 2)
345 352
346 353
347 if __name__ == '__main__': 354 if __name__ == '__main__':
348 import unittest 355 import unittest
349 unittest.main() 356 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