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

Side by Side Diff: tests/scm_unittest.py

Issue 501166: Remove more logic out of trychange.py into scm.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 | « tests/gclient_scm_test.py ('k') | tests/trychange_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) 2006-2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-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 scm.py.""" 6 """Unit tests for scm.py."""
7 7
8 import shutil 8 import shutil
9 import tempfile 9 import tempfile
10 10
11 from gclient_test import BaseTestCase 11 from gclient_test import BaseTestCase
12 import scm 12 import scm
13 from super_mox import mox, SuperMoxBaseTestBase 13 from super_mox import mox, SuperMoxBaseTestBase
14 14
15 15
16 class BaseSCMTestCase(BaseTestCase): 16 class BaseSCMTestCase(BaseTestCase):
17 def setUp(self): 17 def setUp(self):
18 BaseTestCase.setUp(self) 18 BaseTestCase.setUp(self)
19 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall') 19 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall')
20 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter') 20 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter')
21 21
22 22
23 class RootTestCase(BaseSCMTestCase): 23 class RootTestCase(BaseSCMTestCase):
24 def testMembersChanged(self): 24 def testMembersChanged(self):
25 self.mox.ReplayAll() 25 self.mox.ReplayAll()
26 members = [ 26 members = [
27 'GIT', 'SVN', 27 'GIT', 'SVN', 'ValidateEmail',
28 'gclient_utils', 'os', 're', 'shutil', 'subprocess', 'sys', 'tempfile', 28 'gclient_utils', 'os', 're', 'shutil', 'subprocess', 'sys', 'tempfile',
29 'xml', 29 'xml',
30 ] 30 ]
31 # If this test fails, you should add the relevant test. 31 # If this test fails, you should add the relevant test.
32 self.compareMembers(scm, members) 32 self.compareMembers(scm, members)
33 33
34 34
35 class GitWrapperTestCase(SuperMoxBaseTestBase): 35 class GitWrapperTestCase(SuperMoxBaseTestBase):
36 sample_git_import = """blob 36 sample_git_import = """blob
37 mark :1 37 mark :1
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 self.fake_root = self.Dir() 110 self.fake_root = self.Dir()
111 111
112 def tearDown(self): 112 def tearDown(self):
113 shutil.rmtree(self.root_dir) 113 shutil.rmtree(self.root_dir)
114 SuperMoxBaseTestBase.tearDown(self) 114 SuperMoxBaseTestBase.tearDown(self)
115 115
116 def testMembersChanged(self): 116 def testMembersChanged(self):
117 self.mox.ReplayAll() 117 self.mox.ReplayAll()
118 members = [ 118 members = [
119 'COMMAND', 'Capture', 'CaptureStatus', 'FetchUpstreamTuple', 119 'COMMAND', 'Capture', 'CaptureStatus', 'FetchUpstreamTuple',
120 'GenerateDiff', 'GetBranchRef', 'GetEmail', 'GetSVNBranch', 120 'GenerateDiff', 'GetBranch', 'GetBranchRef', 'GetCheckoutRoot',
121 'GetUpstream', 'IsGitSvn', 'ShortBranchName' 121 'GetEmail', 'GetPatchName', 'GetSVNBranch',
122 'GetUpstream', 'IsGitSvn', 'ShortBranchName',
122 ] 123 ]
123 # If this test fails, you should add the relevant test. 124 # If this test fails, you should add the relevant test.
124 self.compareMembers(scm.GIT, members) 125 self.compareMembers(scm.GIT, members)
125 126
126 def testGetEmail(self): 127 def testGetEmail(self):
127 self.mox.StubOutWithMock(scm.GIT, 'Capture') 128 self.mox.StubOutWithMock(scm.GIT, 'Capture')
128 scm.GIT.Capture(['config', 'user.email'], self.fake_root, error_ok=True 129 scm.GIT.Capture(['config', 'user.email'], self.fake_root, error_ok=True
129 ).AndReturn('mini@me.com') 130 ).AndReturn('mini@me.com')
130 self.mox.ReplayAll() 131 self.mox.ReplayAll()
131 self.assertEqual(scm.GIT.GetEmail(self.fake_root), 'mini@me.com') 132 self.assertEqual(scm.GIT.GetEmail(self.fake_root), 'mini@me.com')
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 self.mox.ReplayAll() 307 self.mox.ReplayAll()
307 info = scm.SVN.CaptureStatus(None) 308 info = scm.SVN.CaptureStatus(None)
308 self.assertEquals(info, []) 309 self.assertEquals(info, [])
309 310
310 311
311 if __name__ == '__main__': 312 if __name__ == '__main__':
312 import unittest 313 import unittest
313 unittest.main() 314 unittest.main()
314 315
315 # vim: ts=2:sw=2:tw=80:et: 316 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gclient_scm_test.py ('k') | tests/trychange_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698