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

Side by Side Diff: tests/gcl_unittest.py

Issue 504085: Add --sup_rep support to trychange.py. (Closed)
Patch Set: Created 11 years 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/scm_unittest.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.SVN, 'CaptureInfo')
20 self.mox.StubOutWithMock(gcl.SVN, 'GetCheckoutRoot')
20 self.mox.StubOutWithMock(gcl, 'tempfile') 21 self.mox.StubOutWithMock(gcl, 'tempfile')
21 self.mox.StubOutWithMock(gcl.upload, 'RealMain') 22 self.mox.StubOutWithMock(gcl.upload, 'RealMain')
22 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileRead') 23 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileRead')
23 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileWrite') 24 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileWrite')
25 gcl.REPOSITORY_ROOT = None
24 26
25 27
26 class GclUnittest(GclTestsBase): 28 class GclUnittest(GclTestsBase):
27 """General gcl.py tests.""" 29 """General gcl.py tests."""
28 def testMembersChanged(self): 30 def testMembersChanged(self):
29 self.mox.ReplayAll() 31 self.mox.ReplayAll()
30 members = [ 32 members = [
31 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'Change', 33 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'Change',
32 'ChangeInfo', 'Changes', 'Commit', 'DEFAULT_LINT_IGNORE_REGEX', 34 'ChangeInfo', 'Changes', 'Commit', 'DEFAULT_LINT_IGNORE_REGEX',
33 'DEFAULT_LINT_REGEX', 'DeleteEmptyChangeLists', 'DoPresubmitChecks', 35 'DEFAULT_LINT_REGEX', 'DeleteEmptyChangeLists', 'DoPresubmitChecks',
(...skipping 19 matching lines...) Expand all
53 55
54 def testGetSVNFileProperty(self): 56 def testGetSVNFileProperty(self):
55 # TODO(maruel): TEST ME 57 # TODO(maruel): TEST ME
56 pass 58 pass
57 59
58 def testUnknownFiles(self): 60 def testUnknownFiles(self):
59 # TODO(maruel): TEST ME 61 # TODO(maruel): TEST ME
60 pass 62 pass
61 63
62 def testGetRepositoryRootNone(self): 64 def testGetRepositoryRootNone(self):
63 gcl.REPOSITORY_ROOT = None 65 gcl.os.getcwd().AndReturn(self.fake_root_dir)
64 gcl.os.getcwd().AndReturn("/bleh/prout") 66 gcl.SVN.GetCheckoutRoot(self.fake_root_dir).AndReturn(None)
65 result = {
66 "Repository Root": ""
67 }
68 gcl.SVN.CaptureInfo("/bleh/prout", print_error=False).AndReturn(result)
69 self.mox.ReplayAll() 67 self.mox.ReplayAll()
70 self.assertRaises(Exception, gcl.GetRepositoryRoot) 68 self.assertRaises(gcl.gclient_utils.Error, gcl.GetRepositoryRoot)
71 69
72 def testGetRepositoryRootGood(self): 70 def testGetRepositoryRootGood(self):
73 gcl.REPOSITORY_ROOT = None
74 root_path = gcl.os.path.join('bleh', 'prout', 'pouet') 71 root_path = gcl.os.path.join('bleh', 'prout', 'pouet')
75 gcl.os.getcwd().AndReturn(root_path) 72 gcl.os.getcwd().AndReturn(root_path)
76 result1 = { "Repository Root": "Some root" } 73 gcl.SVN.GetCheckoutRoot(root_path).AndReturn(root_path + '.~')
bradn 2009/12/22 20:38:47 Shouldn't this be an os.path.join ? Why add the .
77 gcl.SVN.CaptureInfo(root_path, print_error=False).AndReturn(result1)
78 results2 = { "Repository Root": "A different root" }
79 gcl.SVN.CaptureInfo(gcl.os.path.dirname(root_path),
80 print_error=False).AndReturn(results2)
81 self.mox.ReplayAll() 74 self.mox.ReplayAll()
82 self.assertEquals(gcl.GetRepositoryRoot(), root_path) 75 self.assertEquals(gcl.GetRepositoryRoot(), root_path + '.~')
83 76
84 def testGetCachedFile(self): 77 def testGetCachedFile(self):
85 # TODO(maruel): TEST ME 78 # TODO(maruel): TEST ME
86 pass 79 pass
87 80
88 def testGetCodeReviewSetting(self): 81 def testGetCodeReviewSetting(self):
89 # TODO(maruel): TEST ME 82 # TODO(maruel): TEST ME
90 pass 83 pass
91 84
92 def testGetChangelistInfoFile(self): 85 def testGetChangelistInfoFile(self):
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 self.mox.ReplayAll() 344 self.mox.ReplayAll()
352 345
353 gcl.UploadCL(change_info, args) 346 gcl.UploadCL(change_info, args)
354 self.assertEquals(change_info.issue, 1) 347 self.assertEquals(change_info.issue, 1)
355 self.assertEquals(change_info.patchset, 2) 348 self.assertEquals(change_info.patchset, 2)
356 349
357 350
358 if __name__ == '__main__': 351 if __name__ == '__main__':
359 import unittest 352 import unittest
360 unittest.main() 353 unittest.main()
OLDNEW
« no previous file with comments | « scm.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698