| OLD | NEW | 
|---|
| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 204     gcl.os.chdir('proout') | 204     gcl.os.chdir('proout') | 
| 205     change_info.GetFileNames().AndReturn(files) | 205     change_info.GetFileNames().AndReturn(files) | 
| 206     gcl.GenerateDiff(files) | 206     gcl.GenerateDiff(files) | 
| 207     gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', | 207     gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', | 
| 208                          '-r', 'georges@example.com', | 208                          '-r', 'georges@example.com', | 
| 209                          '--message=\'\'', '--issue=1'], | 209                          '--message=\'\'', '--issue=1'], | 
| 210                          change_info.patch).AndReturn(("1", | 210                          change_info.patch).AndReturn(("1", | 
| 211                                                                     "2")) | 211                                                                     "2")) | 
| 212     gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 212     gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 
| 213     gcl.os.chdir('somewhere') | 213     gcl.os.chdir('somewhere') | 
|  | 214     gcl.sys.stdout.write("*** Upload does not submit a try; use gcl try to" | 
|  | 215                          " submit a try. ***") | 
|  | 216     gcl.sys.stdout.write("\n") | 
| 214     change_info.Save() | 217     change_info.Save() | 
| 215     gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) | 218     gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) | 
| 216     gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True | 219     gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True | 
| 217         ).AndReturn(change_info) | 220         ).AndReturn(change_info) | 
| 218     self.mox.ReplayAll() | 221     self.mox.ReplayAll() | 
| 219 | 222 | 
| 220     gcl.CMDupload(['naame', '-r', 'georges@example.com']) | 223     gcl.CMDupload(['naame', '-r', 'georges@example.com']) | 
| 221 | 224 | 
| 222   def testServerOverride(self): | 225   def testServerOverride(self): | 
| 223     change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', | 226     change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 234     gcl.GetCodeReviewSetting('PRIVATE') | 237     gcl.GetCodeReviewSetting('PRIVATE') | 
| 235     gcl.os.getcwd().AndReturn('somewhere') | 238     gcl.os.getcwd().AndReturn('somewhere') | 
| 236     gcl.os.chdir(change_info.GetLocalRoot()) | 239     gcl.os.chdir(change_info.GetLocalRoot()) | 
| 237     gcl.GenerateDiff(change_info.GetFileNames()) | 240     gcl.GenerateDiff(change_info.GetFileNames()) | 
| 238     gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a', | 241     gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a', | 
| 239         "--description_file=descfile", | 242         "--description_file=descfile", | 
| 240         "--message=deescription"], change_info.patch).AndReturn(("1", "2")) | 243         "--message=deescription"], change_info.patch).AndReturn(("1", "2")) | 
| 241     gcl.os.remove('descfile') | 244     gcl.os.remove('descfile') | 
| 242     gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 245     gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 
| 243     gcl.os.chdir('somewhere') | 246     gcl.os.chdir('somewhere') | 
|  | 247     gcl.sys.stdout.write("*** Upload does not submit a try; use gcl try to" | 
|  | 248                          " submit a try. ***") | 
|  | 249     gcl.sys.stdout.write("\n") | 
| 244     gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) | 250     gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) | 
| 245     gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True | 251     gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True | 
| 246         ).AndReturn(change_info) | 252         ).AndReturn(change_info) | 
| 247     self.mox.ReplayAll() | 253     self.mox.ReplayAll() | 
| 248 | 254 | 
| 249     gcl.CMDupload(['naame', '--server=a', '--no_watchlists']) | 255     gcl.CMDupload(['naame', '--server=a', '--no_watchlists']) | 
| 250 | 256 | 
| 251   def testNormal(self): | 257   def testNormal(self): | 
| 252     change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', | 258     change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', | 
| 253                                  [('A', 'aa'), ('M', 'bb')], | 259                                  [('A', 'aa'), ('M', 'bb')], | 
| 254                                  self.fake_root_dir) | 260                                  self.fake_root_dir) | 
| 255     self.mox.StubOutWithMock(change_info, 'Save') | 261     self.mox.StubOutWithMock(change_info, 'Save') | 
| 256     change_info.Save() | 262     change_info.Save() | 
| 257     gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) | 263     gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) | 
| 258     gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') | 264     gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') | 
| 259     gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) | 265     gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) | 
| 260     gcl.os.write(42, change_info.description) | 266     gcl.os.write(42, change_info.description) | 
| 261     gcl.os.close(42) | 267     gcl.os.close(42) | 
| 262     gcl.GetCodeReviewSetting('CC_LIST') | 268     gcl.GetCodeReviewSetting('CC_LIST') | 
| 263     gcl.GetCodeReviewSetting('PRIVATE') | 269     gcl.GetCodeReviewSetting('PRIVATE') | 
| 264     gcl.os.getcwd().AndReturn('somewhere') | 270     gcl.os.getcwd().AndReturn('somewhere') | 
| 265     gcl.os.chdir(change_info.GetLocalRoot()) | 271     gcl.os.chdir(change_info.GetLocalRoot()) | 
| 266     gcl.GenerateDiff(change_info.GetFileNames()) | 272     gcl.GenerateDiff(change_info.GetFileNames()) | 
| 267     gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', | 273     gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', | 
| 268         "--description_file=descfile", | 274         "--description_file=descfile", | 
| 269         "--message=deescription"], change_info.patch).AndReturn(("1", "2")) | 275         "--message=deescription"], change_info.patch).AndReturn(("1", "2")) | 
| 270     gcl.os.remove('descfile') | 276     gcl.os.remove('descfile') | 
| 271     gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 277     gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 
| 272     gcl.os.chdir('somewhere') | 278     gcl.os.chdir('somewhere') | 
|  | 279     gcl.sys.stdout.write("*** Upload does not submit a try; use gcl try to" | 
|  | 280                          " submit a try. ***") | 
|  | 281     gcl.sys.stdout.write("\n") | 
| 273     gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) | 282     gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) | 
| 274     gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True | 283     gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True | 
| 275         ).AndReturn(change_info) | 284         ).AndReturn(change_info) | 
| 276     self.mox.ReplayAll() | 285     self.mox.ReplayAll() | 
| 277 | 286 | 
| 278     gcl.CMDupload(['naame', '--no_watchlists']) | 287     gcl.CMDupload(['naame', '--no_watchlists']) | 
| 279     self.assertEquals(change_info.issue, 1) | 288     self.assertEquals(change_info.issue, 1) | 
| 280     self.assertEquals(change_info.patchset, 2) | 289     self.assertEquals(change_info.patchset, 2) | 
| 281 | 290 | 
| 282 | 291 | 
| 283 if __name__ == '__main__': | 292 if __name__ == '__main__': | 
| 284   import unittest | 293   import unittest | 
| 285   unittest.main() | 294   unittest.main() | 
| OLD | NEW | 
|---|