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

Side by Side Diff: tests/scm_unittest.py

Issue 399070: Add scm.*.GetEmail() to retrieve the user email. Use this email for try job emails. (Closed)
Patch Set: Use CaptureInfo() 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 | « 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
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return True 99 return True
100 100
101 def setUp(self): 101 def setUp(self):
102 SuperMoxBaseTestBase.setUp(self) 102 SuperMoxBaseTestBase.setUp(self)
103 self.args = self.Args() 103 self.args = self.Args()
104 self.url = 'git://foo' 104 self.url = 'git://foo'
105 self.root_dir = tempfile.mkdtemp() 105 self.root_dir = tempfile.mkdtemp()
106 self.relpath = '.' 106 self.relpath = '.'
107 self.base_path = scm.os.path.join(self.root_dir, self.relpath) 107 self.base_path = scm.os.path.join(self.root_dir, self.relpath)
108 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) 108 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path)
109 self.fake_root = self.Dir()
109 110
110 def tearDown(self): 111 def tearDown(self):
111 shutil.rmtree(self.root_dir) 112 shutil.rmtree(self.root_dir)
112 SuperMoxBaseTestBase.tearDown(self) 113 SuperMoxBaseTestBase.tearDown(self)
113 114
114 def testMembersChanged(self): 115 def testMembersChanged(self):
115 self.mox.ReplayAll() 116 self.mox.ReplayAll()
116 members = [ 117 members = [
117 'COMMAND', 'Capture', 'CaptureStatus', 118 'COMMAND', 'Capture', 'CaptureStatus', 'GetEmail',
118 ] 119 ]
119 # If this test fails, you should add the relevant test. 120 # If this test fails, you should add the relevant test.
120 self.compareMembers(scm.GIT, members) 121 self.compareMembers(scm.GIT, members)
121 122
123 def testGetEmail(self):
124 self.mox.StubOutWithMock(scm.GIT, 'Capture')
125 scm.GIT.Capture(['config', 'user.email'], self.fake_root).AndReturn('mini@me .com')
126 self.mox.ReplayAll()
127 self.assertEqual(scm.GIT.GetEmail(self.fake_root), 'mini@me.com')
128
122 129
123 class SVNTestCase(BaseSCMTestCase): 130 class SVNTestCase(BaseSCMTestCase):
124 def setUp(self): 131 def setUp(self):
125 BaseSCMTestCase.setUp(self) 132 BaseSCMTestCase.setUp(self)
126 self.root_dir = self.Dir() 133 self.root_dir = self.Dir()
127 self.args = self.Args() 134 self.args = self.Args()
128 self.url = self.Url() 135 self.url = self.Url()
129 self.relpath = 'asf' 136 self.relpath = 'asf'
130 137
131 def testMembersChanged(self): 138 def testMembersChanged(self):
132 self.mox.ReplayAll() 139 self.mox.ReplayAll()
133 members = [ 140 members = [
134 'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo', 141 'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo',
135 'CaptureStatus', 'DiffItem', 'GetFileProperty', 'IsMoved', 'Run', 142 'CaptureStatus', 'DiffItem', 'GetEmail', 'GetFileProperty', 'IsMoved',
136 'RunAndFilterOutput', 'RunAndGetFileList', 143 'ReadEntries', 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput',
144 'RunAndGetFileList',
137 ] 145 ]
138 # If this test fails, you should add the relevant test. 146 # If this test fails, you should add the relevant test.
139 self.compareMembers(scm.SVN, members) 147 self.compareMembers(scm.SVN, members)
140 148
141 def testGetFileInfo(self): 149 def testGetFileInfo(self):
142 xml_text = r"""<?xml version="1.0"?> 150 xml_text = r"""<?xml version="1.0"?>
143 <info> 151 <info>
144 <entry kind="file" path="%s" revision="14628"> 152 <entry kind="file" path="%s" revision="14628">
145 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> 153 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url>
146 <repository><root>http://src.chromium.org/svn</root></repository> 154 <repository><root>http://src.chromium.org/svn</root></repository>
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 self.mox.ReplayAll() 302 self.mox.ReplayAll()
295 info = scm.SVN.CaptureStatus(None) 303 info = scm.SVN.CaptureStatus(None)
296 self.assertEquals(info, []) 304 self.assertEquals(info, [])
297 305
298 306
299 if __name__ == '__main__': 307 if __name__ == '__main__':
300 import unittest 308 import unittest
301 unittest.main() 309 unittest.main()
302 310
303 # vim: ts=2:sw=2:tw=80:et: 311 # 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