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

Side by Side Diff: tests/gcl_unittest.py

Issue 702001: Add ability to specify that all issues are pivate in codereview.settings... (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « gcl.py ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 # Fixes include path. 8 # Fixes include path.
9 from super_mox import mox, SuperMoxTestBase 9 from super_mox import mox, SuperMoxTestBase
10 10
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 self.fake_root_dir) 272 self.fake_root_dir)
273 self.mox.StubOutWithMock(change_info, 'Save') 273 self.mox.StubOutWithMock(change_info, 'Save')
274 args = ['--server=a', '--no_watchlists'] 274 args = ['--server=a', '--no_watchlists']
275 change_info.Save() 275 change_info.Save()
276 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 276 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
277 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 277 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
278 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 278 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
279 gcl.os.write(42, change_info.description) 279 gcl.os.write(42, change_info.description)
280 gcl.os.close(42) 280 gcl.os.close(42)
281 gcl.GetCodeReviewSetting('CC_LIST') 281 gcl.GetCodeReviewSetting('CC_LIST')
282 gcl.GetCodeReviewSetting('PRIVATE')
282 gcl.os.getcwd().AndReturn('somewhere') 283 gcl.os.getcwd().AndReturn('somewhere')
283 gcl.os.chdir(change_info.GetLocalRoot()) 284 gcl.os.chdir(change_info.GetLocalRoot())
284 gcl.GenerateDiff(change_info.GetFileNames()) 285 gcl.GenerateDiff(change_info.GetFileNames())
285 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a', 286 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a',
286 "--description_file=descfile", 287 "--description_file=descfile",
287 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) 288 "--message=deescription"], change_info.patch).AndReturn(("1", "2"))
288 gcl.os.remove('descfile') 289 gcl.os.remove('descfile')
289 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) 290 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5)
290 gcl.os.chdir('somewhere') 291 gcl.os.chdir('somewhere')
291 self.mox.ReplayAll() 292 self.mox.ReplayAll()
292 293
293 gcl.UploadCL(change_info, args) 294 gcl.UploadCL(change_info, args)
294 295
295 def testNoTry(self): 296 def testNoTry(self):
296 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', 297 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
297 [('A', 'aa'), ('M', 'bb')], 298 [('A', 'aa'), ('M', 'bb')],
298 self.fake_root_dir) 299 self.fake_root_dir)
299 change_info.Save = self.mox.CreateMockAnything() 300 change_info.Save = self.mox.CreateMockAnything()
300 args = ['--no-try', '--no_watchlists'] 301 args = ['--no-try', '--no_watchlists']
301 change_info.Save() 302 change_info.Save()
302 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 303 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
303 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 304 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
304 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 305 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
305 gcl.os.write(42, change_info.description) 306 gcl.os.write(42, change_info.description)
306 gcl.os.close(42) 307 gcl.os.close(42)
307 gcl.GetCodeReviewSetting('CC_LIST') 308 gcl.GetCodeReviewSetting('CC_LIST')
309 gcl.GetCodeReviewSetting('PRIVATE')
308 gcl.os.getcwd().AndReturn('somewhere') 310 gcl.os.getcwd().AndReturn('somewhere')
309 gcl.os.chdir(change_info.GetLocalRoot()) 311 gcl.os.chdir(change_info.GetLocalRoot())
310 gcl.GenerateDiff(change_info.GetFileNames()) 312 gcl.GenerateDiff(change_info.GetFileNames())
311 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', 313 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server',
312 "--description_file=descfile", 314 "--description_file=descfile",
313 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) 315 "--message=deescription"], change_info.patch).AndReturn(("1", "2"))
314 gcl.os.remove('descfile') 316 gcl.os.remove('descfile')
315 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) 317 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5)
316 gcl.os.chdir('somewhere') 318 gcl.os.chdir('somewhere')
317 self.mox.ReplayAll() 319 self.mox.ReplayAll()
318 320
319 gcl.UploadCL(change_info, args) 321 gcl.UploadCL(change_info, args)
320 322
321 def testNormal(self): 323 def testNormal(self):
322 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', 324 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
323 [('A', 'aa'), ('M', 'bb')], 325 [('A', 'aa'), ('M', 'bb')],
324 self.fake_root_dir) 326 self.fake_root_dir)
325 self.mox.StubOutWithMock(change_info, 'Save') 327 self.mox.StubOutWithMock(change_info, 'Save')
326 args = ['--no_watchlists'] 328 args = ['--no_watchlists']
327 change_info.Save() 329 change_info.Save()
328 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 330 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
329 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 331 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
330 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 332 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
331 gcl.os.write(42, change_info.description) 333 gcl.os.write(42, change_info.description)
332 gcl.os.close(42) 334 gcl.os.close(42)
333 gcl.GetCodeReviewSetting('CC_LIST') 335 gcl.GetCodeReviewSetting('CC_LIST')
336 gcl.GetCodeReviewSetting('PRIVATE')
334 gcl.os.getcwd().AndReturn('somewhere') 337 gcl.os.getcwd().AndReturn('somewhere')
335 gcl.os.chdir(change_info.GetLocalRoot()) 338 gcl.os.chdir(change_info.GetLocalRoot())
336 gcl.GenerateDiff(change_info.GetFileNames()) 339 gcl.GenerateDiff(change_info.GetFileNames())
337 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', 340 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server',
338 "--description_file=descfile", 341 "--description_file=descfile",
339 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) 342 "--message=deescription"], change_info.patch).AndReturn(("1", "2"))
340 gcl.os.remove('descfile') 343 gcl.os.remove('descfile')
341 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) 344 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5)
342 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True') 345 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True')
343 gcl.TryChange(change_info, [], swallow_exception=True) 346 gcl.TryChange(change_info, [], swallow_exception=True)
344 gcl.os.chdir('somewhere') 347 gcl.os.chdir('somewhere')
345 self.mox.ReplayAll() 348 self.mox.ReplayAll()
346 349
347 gcl.UploadCL(change_info, args) 350 gcl.UploadCL(change_info, args)
348 self.assertEquals(change_info.issue, 1) 351 self.assertEquals(change_info.issue, 1)
349 self.assertEquals(change_info.patchset, 2) 352 self.assertEquals(change_info.patchset, 2)
350 353
351 354
352 if __name__ == '__main__': 355 if __name__ == '__main__':
353 import unittest 356 import unittest
354 unittest.main() 357 unittest.main()
OLDNEW
« no previous file with comments | « gcl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698