| OLD | NEW |
| 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 # Local imports | 8 # Local imports |
| 9 import gcl | 9 import gcl |
| 10 from super_mox import mox, SuperMoxTestBase | 10 from super_mox import mox, SuperMoxTestBase |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 pass | 130 pass |
| 131 | 131 |
| 132 def testTryChange(self): | 132 def testTryChange(self): |
| 133 # TODO(maruel): TEST ME | 133 # TODO(maruel): TEST ME |
| 134 pass | 134 pass |
| 135 | 135 |
| 136 def testCommit(self): | 136 def testCommit(self): |
| 137 # TODO(maruel): TEST ME | 137 # TODO(maruel): TEST ME |
| 138 pass | 138 pass |
| 139 | 139 |
| 140 def testCommitWithContributor(self): |
| 141 self.mox.StubOutWithMock(gcl, 'OptionallyDoPresubmitChecks') |
| 142 self.mox.StubOutWithMock(gcl, 'GetIssueDescription') |
| 143 self.mox.StubOutWithMock(gcl, 'GetCodeReviewSetting') |
| 144 self.mox.StubOutWithMock(gcl.ChangeInfo, 'GetLocalRoot') |
| 145 self.mox.StubOutWithMock(gcl.ChangeInfo, 'Delete') |
| 146 |
| 147 root_dir1 = self.Dir() |
| 148 root_dir2 = self.Dir() |
| 149 |
| 150 change_info = gcl.ChangeInfo('test-commit-contributor', 0, 0, 'Testing', |
| 151 [('A', 'aa'), ('B', 'bb')], self.fake_root_dir) |
| 152 |
| 153 expected_text = """Testing\nPatch from john""" |
| 154 |
| 155 # Call sequence |
| 156 gcl.DoPresubmitChecks(change_info, True, True).AndReturn(True) |
| 157 file_handle = 42 |
| 158 file_name = "descfile" |
| 159 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') |
| 160 gcl.tempfile.mkstemp(text=True).AndReturn((file_handle, file_name)) |
| 161 gcl.os.write(file_handle, expected_text) |
| 162 gcl.os.close(file_handle) |
| 163 gcl.os.getcwd().AndReturn(root_dir1) |
| 164 change_info.GetLocalRoot().AndReturn(root_dir2) |
| 165 gcl.os.chdir(root_dir2) |
| 166 gcl.os.remove(file_name) |
| 167 gcl.RunShell(['svn', 'commit', '--file=..', |
| 168 '--targets=..']).AndReturn("Committed revision") |
| 169 |
| 170 args = ['-c', 'john'] |
| 171 # Now time to actually run the test: |
| 172 self.mox.ReplayAll() |
| 173 gcl.Commit(change_info, args) |
| 174 |
| 140 def testChange(self): | 175 def testChange(self): |
| 141 # TODO(maruel): TEST ME | 176 # TODO(maruel): TEST ME |
| 142 pass | 177 pass |
| 143 | 178 |
| 144 def testLint(self): | 179 def testLint(self): |
| 145 # TODO(maruel): TEST ME | 180 # TODO(maruel): TEST ME |
| 146 pass | 181 pass |
| 147 | 182 |
| 148 def testDoPresubmitChecks(self): | 183 def testDoPresubmitChecks(self): |
| 149 # TODO(maruel): TEST ME | 184 # TODO(maruel): TEST ME |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 self.mox.ReplayAll() | 386 self.mox.ReplayAll() |
| 352 | 387 |
| 353 gcl.UploadCL(change_info, args) | 388 gcl.UploadCL(change_info, args) |
| 354 self.assertEquals(change_info.issue, 1) | 389 self.assertEquals(change_info.issue, 1) |
| 355 self.assertEquals(change_info.patchset, 2) | 390 self.assertEquals(change_info.patchset, 2) |
| 356 | 391 |
| 357 | 392 |
| 358 if __name__ == '__main__': | 393 if __name__ == '__main__': |
| 359 import unittest | 394 import unittest |
| 360 unittest.main() | 395 unittest.main() |
| OLD | NEW |