OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
7 | 7 |
8 import json | 8 import json |
9 import os | 9 import os |
10 import StringIO | 10 import StringIO |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 self.fail('@%d\n' | 321 self.fail('@%d\n' |
322 ' Expected: %r\n' | 322 ' Expected: %r\n' |
323 ' Actual: %r' % ( | 323 ' Actual: %r' % ( |
324 len(self._calls_done), expected_args, args)) | 324 len(self._calls_done), expected_args, args)) |
325 | 325 |
326 self._calls_done.append(top) | 326 self._calls_done.append(top) |
327 if isinstance(result, Exception): | 327 if isinstance(result, Exception): |
328 raise result | 328 raise result |
329 return result | 329 return result |
330 | 330 |
| 331 def test_LoadCodereviewSettingsFromFile_gerrit(self): |
| 332 codereview_file = StringIO.StringIO('GERRIT_HOST: true') |
| 333 self.calls = [ |
| 334 ((['git', 'config', '--unset-all', 'rietveld.cc'],), CERR1), |
| 335 ((['git', 'config', '--unset-all', 'rietveld.private'],), CERR1), |
| 336 ((['git', 'config', '--unset-all', 'rietveld.tree-status-url'],), CERR1), |
| 337 ((['git', 'config', '--unset-all', 'rietveld.viewvc-url'],), CERR1), |
| 338 ((['git', 'config', '--unset-all', 'rietveld.bug-prefix'],), CERR1), |
| 339 ((['git', 'config', '--unset-all', 'rietveld.cpplint-regex'],), CERR1), |
| 340 ((['git', 'config', '--unset-all', 'rietveld.force-https-commit-url'],), |
| 341 CERR1), |
| 342 ((['git', 'config', '--unset-all', 'rietveld.cpplint-ignore-regex'],), |
| 343 CERR1), |
| 344 ((['git', 'config', '--unset-all', 'rietveld.project'],), CERR1), |
| 345 ((['git', 'config', '--unset-all', 'rietveld.pending-ref-prefix'],), |
| 346 CERR1), |
| 347 ((['git', 'config', '--unset-all', 'rietveld.git-number-footer'],), |
| 348 CERR1), |
| 349 ((['git', 'config', '--unset-all', 'rietveld.run-post-upload-hook'],), |
| 350 CERR1), |
| 351 ((['git', 'config', 'gerrit.host', 'true'],), ''), |
| 352 ] |
| 353 self.assertIsNone(git_cl.LoadCodereviewSettingsFromFile(codereview_file)) |
| 354 |
331 @classmethod | 355 @classmethod |
332 def _is_gerrit_calls(cls, gerrit=False): | 356 def _is_gerrit_calls(cls, gerrit=False): |
333 return [((['git', 'config', 'rietveld.autoupdate'],), ''), | 357 return [((['git', 'config', 'rietveld.autoupdate'],), ''), |
334 ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] | 358 ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] |
335 | 359 |
336 @classmethod | 360 @classmethod |
337 def _upload_calls(cls, similarity, find_copies, private): | 361 def _upload_calls(cls, similarity, find_copies, private): |
338 return (cls._git_base_calls(similarity, find_copies) + | 362 return (cls._git_base_calls(similarity, find_copies) + |
339 cls._git_upload_calls(private)) | 363 cls._git_upload_calls(private)) |
340 | 364 |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 self.assertNotRegexpMatches(sys.stdout.getvalue(), 'Warning') | 2145 self.assertNotRegexpMatches(sys.stdout.getvalue(), 'Warning') |
2122 self.assertRegexpMatches(sys.stdout.getvalue(), '^Failures:') | 2146 self.assertRegexpMatches(sys.stdout.getvalue(), '^Failures:') |
2123 self.assertRegexpMatches(sys.stdout.getvalue(), 'Started:') | 2147 self.assertRegexpMatches(sys.stdout.getvalue(), 'Started:') |
2124 self.assertRegexpMatches(sys.stdout.getvalue(), '2 try jobs') | 2148 self.assertRegexpMatches(sys.stdout.getvalue(), '2 try jobs') |
2125 | 2149 |
2126 | 2150 |
2127 if __name__ == '__main__': | 2151 if __name__ == '__main__': |
2128 git_cl.logging.basicConfig( | 2152 git_cl.logging.basicConfig( |
2129 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 2153 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
2130 unittest.main() | 2154 unittest.main() |
OLD | NEW |