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

Side by Side Diff: tests/gcl_unittest.py

Issue 125051: Fix gcl breakage. (Closed)
Patch Set: Created 11 years, 6 months 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 | « presubmit_support.py ('k') | tests/presubmit_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 import unittest 8 import unittest
9 9
10 # Local imports 10 # Local imports
11 import gcl 11 import gcl
12 import super_mox 12 import super_mox
13 from super_mox import mox 13 from super_mox import mox
14 14
15 15
16 class GclTestsBase(super_mox.SuperMoxTestBase): 16 class GclTestsBase(super_mox.SuperMoxTestBase):
17 """Setups and tear downs the mocks but doesn't test anything as-is.""" 17 """Setups and tear downs the mocks but doesn't test anything as-is."""
18 def setUp(self): 18 def setUp(self):
19 super_mox.SuperMoxTestBase.setUp(self) 19 super_mox.SuperMoxTestBase.setUp(self)
20 self.fake_root_dir = self.RootDir()
20 self.mox.StubOutWithMock(gcl, 'RunShell') 21 self.mox.StubOutWithMock(gcl, 'RunShell')
21 self.mox.StubOutWithMock(gcl.gclient, 'CaptureSVNInfo') 22 self.mox.StubOutWithMock(gcl.gclient, 'CaptureSVNInfo')
22 self.mox.StubOutWithMock(gcl.os, 'getcwd') 23 self.mox.StubOutWithMock(gcl.os, 'getcwd')
23 self.mox.StubOutWithMock(gcl.os, 'chdir') 24 self.mox.StubOutWithMock(gcl.os, 'chdir')
24 self.mox.StubOutWithMock(gcl.os, 'close') 25 self.mox.StubOutWithMock(gcl.os, 'close')
25 self.mox.StubOutWithMock(gcl.os, 'remove') 26 self.mox.StubOutWithMock(gcl.os, 'remove')
26 self.mox.StubOutWithMock(gcl.os, 'write') 27 self.mox.StubOutWithMock(gcl.os, 'write')
27 self.mox.StubOutWithMock(gcl.os.path, 'exists') 28 self.mox.StubOutWithMock(gcl.os.path, 'exists')
28 self.mox.StubOutWithMock(gcl.os.path, 'isdir') 29 self.mox.StubOutWithMock(gcl.os.path, 'isdir')
29 self.mox.StubOutWithMock(gcl.os.path, 'isfile') 30 self.mox.StubOutWithMock(gcl.os.path, 'isfile')
(...skipping 23 matching lines...) Expand all
53 'PresubmitCL', 'ReadFile', 'REPOSITORY_ROOT', 'RunShell', 54 'PresubmitCL', 'ReadFile', 'REPOSITORY_ROOT', 'RunShell',
54 'RunShellWithReturnCode', 'SendToRietveld', 'TryChange', 55 'RunShellWithReturnCode', 'SendToRietveld', 'TryChange',
55 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile', 56 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile',
56 'gclient', 'getpass', 'main', 'os', 'random', 're', 57 'gclient', 'getpass', 'main', 'os', 'random', 're',
57 'shutil', 'string', 'subprocess', 'sys', 'tempfile', 58 'shutil', 'string', 'subprocess', 'sys', 'tempfile',
58 'upload', 'urllib2', 'xml', 59 'upload', 'urllib2', 'xml',
59 ] 60 ]
60 # If this test fails, you should add the relevant test. 61 # If this test fails, you should add the relevant test.
61 self.compareMembers(gcl, members) 62 self.compareMembers(gcl, members)
62 63
64 def testIsSVNMoved(self):
65 # TODO(maruel): TEST ME
66 pass
63 67
64 def testHelp(self): 68 def testGetSVNFileProperty(self):
65 self.mox.StubOutWithMock(gcl.sys, 'stdout') 69 # TODO(maruel): TEST ME
66 gcl.sys.stdout.write(mox.StrContains('GCL is a wrapper for Subversion')) 70 pass
67 gcl.sys.stdout.write('\n') 71
68 self.mox.ReplayAll() 72 def testUnknownFiles(self):
69 gcl.Help() 73 # TODO(maruel): TEST ME
74 pass
70 75
71 def testGetRepositoryRootNone(self): 76 def testGetRepositoryRootNone(self):
72 gcl.REPOSITORY_ROOT = None 77 gcl.REPOSITORY_ROOT = None
73 gcl.os.getcwd().AndReturn("/bleh/prout") 78 gcl.os.getcwd().AndReturn("/bleh/prout")
74 result = { 79 result = {
75 "Repository Root": "" 80 "Repository Root": ""
76 } 81 }
77 gcl.gclient.CaptureSVNInfo("/bleh/prout", print_error=False).AndReturn( 82 gcl.gclient.CaptureSVNInfo("/bleh/prout", print_error=False).AndReturn(
78 result) 83 result)
79 self.mox.ReplayAll() 84 self.mox.ReplayAll()
80 self.assertRaises(Exception, gcl.GetRepositoryRoot) 85 self.assertRaises(Exception, gcl.GetRepositoryRoot)
81 86
82 def testGetRepositoryRootGood(self): 87 def testGetRepositoryRootGood(self):
83 gcl.REPOSITORY_ROOT = None 88 gcl.REPOSITORY_ROOT = None
84 root_path = gcl.os.path.join('bleh', 'prout', 'pouet') 89 root_path = gcl.os.path.join('bleh', 'prout', 'pouet')
85 gcl.os.getcwd().AndReturn(root_path) 90 gcl.os.getcwd().AndReturn(root_path)
86 result1 = { "Repository Root": "Some root" } 91 result1 = { "Repository Root": "Some root" }
87 gcl.gclient.CaptureSVNInfo(root_path, print_error=False).AndReturn(result1) 92 gcl.gclient.CaptureSVNInfo(root_path, print_error=False).AndReturn(result1)
88 gcl.os.getcwd().AndReturn(root_path) 93 gcl.os.getcwd().AndReturn(root_path)
89 results2 = { "Repository Root": "A different root" } 94 results2 = { "Repository Root": "A different root" }
90 gcl.gclient.CaptureSVNInfo( 95 gcl.gclient.CaptureSVNInfo(
91 gcl.os.path.dirname(root_path), 96 gcl.os.path.dirname(root_path),
92 print_error=False).AndReturn(results2) 97 print_error=False).AndReturn(results2)
93 self.mox.ReplayAll() 98 self.mox.ReplayAll()
94 self.assertEquals(gcl.GetRepositoryRoot(), root_path) 99 self.assertEquals(gcl.GetRepositoryRoot(), root_path)
95 100
101 def testGetCachedFile(self):
102 # TODO(maruel): TEST ME
103 pass
104
105 def testGetCodeReviewSetting(self):
106 # TODO(maruel): TEST ME
107 pass
108
109 def testGetChangelistInfoFile(self):
110 # TODO(maruel): TEST ME
111 pass
112
113 def testLoadChangelistInfoForMultiple(self):
114 # TODO(maruel): TEST ME
115 pass
116
117 def testGetModifiedFiles(self):
118 # TODO(maruel): TEST ME
119 pass
120
121 def testGetFilesNotInCL(self):
122 # TODO(maruel): TEST ME
123 pass
124
125 def testSendToRietveld(self):
126 # TODO(maruel): TEST ME
127 pass
128
129 def testOpened(self):
130 # TODO(maruel): TEST ME
131 pass
132
133 def testHelp(self):
134 self.mox.StubOutWithMock(gcl.sys, 'stdout')
135 gcl.sys.stdout.write(mox.StrContains('GCL is a wrapper for Subversion'))
136 gcl.sys.stdout.write('\n')
137 self.mox.ReplayAll()
138 gcl.Help()
139
140 def testGenerateDiff(self):
141 # TODO(maruel): TEST ME
142 pass
143
144 def testPresubmitCL(self):
145 # TODO(maruel): TEST ME
146 pass
147
148 def testTryChange(self):
149 # TODO(maruel): TEST ME
150 pass
151
152 def testCommit(self):
153 # TODO(maruel): TEST ME
154 pass
155
156 def testChange(self):
157 # TODO(maruel): TEST ME
158 pass
159
160 def testLint(self):
161 # TODO(maruel): TEST ME
162 pass
163
164 def testDoPresubmitChecks(self):
165 # TODO(maruel): TEST ME
166 pass
167
96 168
97 class ChangeInfoUnittest(GclTestsBase): 169 class ChangeInfoUnittest(GclTestsBase):
98 def setUp(self): 170 def setUp(self):
99 GclTestsBase.setUp(self) 171 GclTestsBase.setUp(self)
100 self.mox.StubOutWithMock(gcl, 'GetChangelistInfoFile') 172 self.mox.StubOutWithMock(gcl, 'GetChangelistInfoFile')
101 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot') 173 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot')
102 174
103 def testChangeInfoMembers(self): 175 def testChangeInfoMembers(self):
104 gcl.GetRepositoryRoot().AndReturn('prout')
105 self.mox.ReplayAll() 176 self.mox.ReplayAll()
106 members = [ 177 members = [
107 'CloseIssue', 'Delete', 'GetFiles', 'GetFileNames', 'GetLocalRoot', 178 'CloseIssue', 'Delete', 'GetFiles', 'GetFileNames', 'GetLocalRoot',
108 'Load', 'MissingTests', 'Save', 'UpdateRietveldDescription', 179 'Load', 'MissingTests', 'Save', 'UpdateRietveldDescription',
109 'description', 'issue', 'name', 180 'description', 'issue', 'name',
110 'patch', 'patchset', 181 'patch', 'patchset',
111 ] 182 ]
112 # If this test fails, you should add the relevant test. 183 # If this test fails, you should add the relevant test.
113 self.compareMembers(gcl.ChangeInfo('', 0, 0, '', None), members) 184 self.compareMembers(gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir),
185 members)
114 186
115 def testChangeInfoBase(self): 187 def testChangeInfoBase(self):
116 files = [('M', 'foo'), ('A', 'bar')] 188 files = [('M', 'foo'), ('A', 'bar')]
117 gcl.GetRepositoryRoot().AndReturn('prout')
118 self.mox.ReplayAll() 189 self.mox.ReplayAll()
119 o = gcl.ChangeInfo('name2', '42', '53', 'description2', files) 190 o = gcl.ChangeInfo('name2', '42', '53', 'description2', files,
191 self.fake_root_dir)
120 self.assertEquals(o.name, 'name2') 192 self.assertEquals(o.name, 'name2')
121 self.assertEquals(o.issue, 42) 193 self.assertEquals(o.issue, 42)
122 self.assertEquals(o.patchset, 53) 194 self.assertEquals(o.patchset, 53)
123 self.assertEquals(o.description, 'description2') 195 self.assertEquals(o.description, 'description2')
124 self.assertEquals(o.patch, None) 196 self.assertEquals(o.patch, None)
125 self.assertEquals(o.GetFileNames(), ['foo', 'bar']) 197 self.assertEquals(o.GetFileNames(), ['foo', 'bar'])
126 self.assertEquals(o.GetFiles(), files) 198 self.assertEquals(o.GetFiles(), files)
127 self.assertEquals(o.GetLocalRoot(), 'prout') 199 self.assertEquals(o.GetLocalRoot(), self.fake_root_dir)
128 200
129 def testLoadWithIssue(self): 201 def testLoadWithIssue(self):
130 description = ["This is some description.", "force an extra separator."] 202 description = ["This is some description.", "force an extra separator."]
131 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh') 203 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh')
132 gcl.os.path.exists('bleeeh').AndReturn(True) 204 gcl.os.path.exists('bleeeh').AndReturn(True)
133 gcl.ReadFile('bleeeh').AndReturn( 205 gcl.ReadFile('bleeeh').AndReturn(
134 gcl.ChangeInfo._SEPARATOR.join(["42,53", "G b.cc"] + description)) 206 gcl.ChangeInfo._SEPARATOR.join(["42,53", "G b.cc"] + description))
135 gcl.GetRepositoryRoot().AndReturn('prout')
136 self.mox.ReplayAll() 207 self.mox.ReplayAll()
137 208
138 change_info = gcl.ChangeInfo.Load('bleh', True, False) 209 change_info = gcl.ChangeInfo.Load('bleh', self.fake_root_dir, True, False)
139 self.assertEquals(change_info.name, 'bleh') 210 self.assertEquals(change_info.name, 'bleh')
140 self.assertEquals(change_info.issue, 42) 211 self.assertEquals(change_info.issue, 42)
141 self.assertEquals(change_info.patchset, 53) 212 self.assertEquals(change_info.patchset, 53)
142 self.assertEquals(change_info.description, 213 self.assertEquals(change_info.description,
143 gcl.ChangeInfo._SEPARATOR.join(description)) 214 gcl.ChangeInfo._SEPARATOR.join(description))
144 self.assertEquals(change_info.GetFiles(), [('G ', 'b.cc')]) 215 self.assertEquals(change_info.GetFiles(), [('G ', 'b.cc')])
145 216
146 def testLoadEmpty(self): 217 def testLoadEmpty(self):
147 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh') 218 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh')
148 gcl.os.path.exists('bleeeh').AndReturn(True) 219 gcl.os.path.exists('bleeeh').AndReturn(True)
149 gcl.ReadFile('bleeeh').AndReturn( 220 gcl.ReadFile('bleeeh').AndReturn(
150 gcl.ChangeInfo._SEPARATOR.join(["", "", ""])) 221 gcl.ChangeInfo._SEPARATOR.join(["", "", ""]))
151 gcl.GetRepositoryRoot().AndReturn('prout')
152 self.mox.ReplayAll() 222 self.mox.ReplayAll()
153 223
154 change_info = gcl.ChangeInfo.Load('bleh', True, False) 224 change_info = gcl.ChangeInfo.Load('bleh', self.fake_root_dir, True, False)
155 self.assertEquals(change_info.name, 'bleh') 225 self.assertEquals(change_info.name, 'bleh')
156 self.assertEquals(change_info.issue, 0) 226 self.assertEquals(change_info.issue, 0)
157 self.assertEquals(change_info.patchset, 0) 227 self.assertEquals(change_info.patchset, 0)
158 self.assertEquals(change_info.description, "") 228 self.assertEquals(change_info.description, "")
159 self.assertEquals(change_info.GetFiles(), []) 229 self.assertEquals(change_info.GetFiles(), [])
160 230
161 def testSaveEmpty(self): 231 def testSaveEmpty(self):
162 gcl.GetChangelistInfoFile('').AndReturn('foo') 232 gcl.GetChangelistInfoFile('').AndReturn('foo')
163 gcl.WriteFile('foo', gcl.ChangeInfo._SEPARATOR.join(['0, 0', '', ''])) 233 gcl.WriteFile('foo', gcl.ChangeInfo._SEPARATOR.join(['0, 0', '', '']))
164 gcl.GetRepositoryRoot().AndReturn('prout')
165 self.mox.ReplayAll() 234 self.mox.ReplayAll()
166 change_info = gcl.ChangeInfo('', 0, 0, '', None) 235
236 change_info = gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir)
167 change_info.Save() 237 change_info.Save()
168 238
169 239
170 class UploadCLUnittest(GclTestsBase): 240 class UploadCLUnittest(GclTestsBase):
171 def setUp(self): 241 def setUp(self):
172 GclTestsBase.setUp(self) 242 GclTestsBase.setUp(self)
173 self.mox.StubOutWithMock(gcl, 'DoPresubmitChecks') 243 self.mox.StubOutWithMock(gcl, 'DoPresubmitChecks')
174 self.mox.StubOutWithMock(gcl, 'GenerateDiff') 244 self.mox.StubOutWithMock(gcl, 'GenerateDiff')
175 self.mox.StubOutWithMock(gcl, 'GetCodeReviewSetting') 245 self.mox.StubOutWithMock(gcl, 'GetCodeReviewSetting')
176 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot') 246 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot')
(...skipping 25 matching lines...) Expand all
202 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True') 272 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True')
203 gcl.TryChange(change_info, [], swallow_exception=True) 273 gcl.TryChange(change_info, [], swallow_exception=True)
204 gcl.os.chdir('somewhere') 274 gcl.os.chdir('somewhere')
205 change_info.Save() 275 change_info.Save()
206 self.mox.ReplayAll() 276 self.mox.ReplayAll()
207 277
208 gcl.UploadCL(change_info, args) 278 gcl.UploadCL(change_info, args)
209 279
210 def testServerOverride(self): 280 def testServerOverride(self):
211 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', 281 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
212 [('A', 'aa'), ('M', 'bb')]) 282 [('A', 'aa'), ('M', 'bb')],
283 self.fake_root_dir)
213 self.mox.StubOutWithMock(change_info, 'Save') 284 self.mox.StubOutWithMock(change_info, 'Save')
214 args = ['--server=a', '--no_watchlists'] 285 args = ['--server=a', '--no_watchlists']
215 change_info.Save() 286 change_info.Save()
216 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 287 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
217 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 288 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
218 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 289 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
219 gcl.os.write(42, change_info.description) 290 gcl.os.write(42, change_info.description)
220 gcl.os.close(42) 291 gcl.os.close(42)
221 gcl.GetCodeReviewSetting('CC_LIST') 292 gcl.GetCodeReviewSetting('CC_LIST')
222 gcl.os.getcwd().AndReturn('somewhere') 293 gcl.os.getcwd().AndReturn('somewhere')
223 gcl.os.chdir(change_info.GetLocalRoot()) 294 gcl.os.chdir(change_info.GetLocalRoot())
224 gcl.GenerateDiff(change_info.GetFileNames()) 295 gcl.GenerateDiff(change_info.GetFileNames())
225 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a', 296 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a',
226 "--description_file=descfile", 297 "--description_file=descfile",
227 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) 298 "--message=deescription"], change_info.patch).AndReturn(("1", "2"))
228 gcl.os.remove('descfile') 299 gcl.os.remove('descfile')
229 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) 300 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5)
230 gcl.os.chdir('somewhere') 301 gcl.os.chdir('somewhere')
231 self.mox.ReplayAll() 302 self.mox.ReplayAll()
232 303
233 # To balance out the call in gcl.ChangeInfo.__init__().
234 gcl.GetRepositoryRoot()
235 gcl.UploadCL(change_info, args) 304 gcl.UploadCL(change_info, args)
236 305
237 def testNoTry(self): 306 def testNoTry(self):
238 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', 307 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
239 [('A', 'aa'), ('M', 'bb')]) 308 [('A', 'aa'), ('M', 'bb')],
309 self.fake_root_dir)
240 change_info.Save = self.mox.CreateMockAnything() 310 change_info.Save = self.mox.CreateMockAnything()
241 args = ['--no-try', '--no_watchlists'] 311 args = ['--no-try', '--no_watchlists']
242 change_info.Save() 312 change_info.Save()
243 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 313 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
244 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 314 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
245 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 315 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
246 gcl.os.write(42, change_info.description) 316 gcl.os.write(42, change_info.description)
247 gcl.os.close(42) 317 gcl.os.close(42)
248 gcl.GetCodeReviewSetting('CC_LIST') 318 gcl.GetCodeReviewSetting('CC_LIST')
249 gcl.os.getcwd().AndReturn('somewhere') 319 gcl.os.getcwd().AndReturn('somewhere')
250 gcl.os.chdir(change_info.GetLocalRoot()) 320 gcl.os.chdir(change_info.GetLocalRoot())
251 gcl.GenerateDiff(change_info.GetFileNames()) 321 gcl.GenerateDiff(change_info.GetFileNames())
252 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', 322 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server',
253 "--description_file=descfile", 323 "--description_file=descfile",
254 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) 324 "--message=deescription"], change_info.patch).AndReturn(("1", "2"))
255 gcl.os.remove('descfile') 325 gcl.os.remove('descfile')
256 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) 326 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5)
257 gcl.os.chdir('somewhere') 327 gcl.os.chdir('somewhere')
258 self.mox.ReplayAll() 328 self.mox.ReplayAll()
259 329
260 # To balance out the call in gcl.ChangeInfo.__init__().
261 gcl.GetRepositoryRoot()
262 gcl.UploadCL(change_info, args) 330 gcl.UploadCL(change_info, args)
263 331
264 def testNormal(self): 332 def testNormal(self):
265 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', 333 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
266 ['aa', 'bb']) 334 [('A', 'aa'), ('M', 'bb')],
335 self.fake_root_dir)
267 self.mox.StubOutWithMock(change_info, 'Save') 336 self.mox.StubOutWithMock(change_info, 'Save')
268 args = ['--no_watchlists'] 337 args = ['--no_watchlists']
269 change_info.Save() 338 change_info.Save()
270 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 339 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
271 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 340 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
272 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 341 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
273 gcl.os.write(42, change_info.description) 342 gcl.os.write(42, change_info.description)
274 gcl.os.close(42) 343 gcl.os.close(42)
275 gcl.GetCodeReviewSetting('CC_LIST') 344 gcl.GetCodeReviewSetting('CC_LIST')
276 gcl.os.getcwd().AndReturn('somewhere') 345 gcl.os.getcwd().AndReturn('somewhere')
277 gcl.os.chdir(change_info.GetLocalRoot()) 346 gcl.os.chdir(change_info.GetLocalRoot())
278 gcl.GenerateDiff(change_info.GetFileNames()) 347 gcl.GenerateDiff(change_info.GetFileNames())
279 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', 348 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server',
280 "--description_file=descfile", 349 "--description_file=descfile",
281 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) 350 "--message=deescription"], change_info.patch).AndReturn(("1", "2"))
282 gcl.os.remove('descfile') 351 gcl.os.remove('descfile')
283 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) 352 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5)
284 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True') 353 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True')
285 gcl.TryChange(change_info, [], swallow_exception=True) 354 gcl.TryChange(change_info, [], swallow_exception=True)
286 gcl.os.chdir('somewhere') 355 gcl.os.chdir('somewhere')
287 self.mox.ReplayAll() 356 self.mox.ReplayAll()
288 357
289 # To balance out the call in gcl.ChangeInfo.__init__().
290 gcl.GetRepositoryRoot()
291 gcl.UploadCL(change_info, args) 358 gcl.UploadCL(change_info, args)
292 self.assertEquals(change_info.issue, 1) 359 self.assertEquals(change_info.issue, 1)
293 self.assertEquals(change_info.patchset, 2) 360 self.assertEquals(change_info.patchset, 2)
294 361
295 362
296 if __name__ == '__main__': 363 if __name__ == '__main__':
297 unittest.main() 364 unittest.main()
OLDNEW
« no previous file with comments | « presubmit_support.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698