| 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 os | 8 import os |
| 9 import StringIO | 9 import StringIO |
| 10 import stat | 10 import stat |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 return path | 642 return path |
| 643 self.mock(git_cl.os.path, 'abspath', AbsPath) | 643 self.mock(git_cl.os.path, 'abspath', AbsPath) |
| 644 commit_msg_path = os.path.join(src_dir, '.git', 'hooks', 'commit-msg') | 644 commit_msg_path = os.path.join(src_dir, '.git', 'hooks', 'commit-msg') |
| 645 def Exists(path): | 645 def Exists(path): |
| 646 if path == commit_msg_path: | 646 if path == commit_msg_path: |
| 647 return False | 647 return False |
| 648 # others paths, such as /usr/share/locale/.... | 648 # others paths, such as /usr/share/locale/.... |
| 649 return True | 649 return True |
| 650 self.mock(git_cl.os.path, 'exists', Exists) | 650 self.mock(git_cl.os.path, 'exists', Exists) |
| 651 self.mock(git_cl, 'urlretrieve', self._mocked_call) | 651 self.mock(git_cl, 'urlretrieve', self._mocked_call) |
| 652 self.mock(git_cl, 'checkHookScript', self._mocked_call) |
| 652 self.calls = [ | 653 self.calls = [ |
| 653 ((['git', 'config', 'rietveld.server', | 654 ((['git', 'config', 'rietveld.server', |
| 654 'gerrit.chromium.org'],), ''), | 655 'gerrit.chromium.org'],), ''), |
| 655 ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''), | 656 ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''), |
| 656 ((['git', 'config', '--unset-all', | 657 ((['git', 'config', '--unset-all', |
| 657 'rietveld.private'],), ''), | 658 'rietveld.private'],), ''), |
| 658 ((['git', 'config', '--unset-all', | 659 ((['git', 'config', '--unset-all', |
| 659 'rietveld.tree-status-url'],), ''), | 660 'rietveld.tree-status-url'],), ''), |
| 660 ((['git', 'config', '--unset-all', | 661 ((['git', 'config', '--unset-all', |
| 661 'rietveld.viewvc-url'],), ''), | 662 'rietveld.viewvc-url'],), ''), |
| 662 ((['git', 'config', 'gerrit.host', | 663 ((['git', 'config', 'gerrit.host', |
| 663 'gerrit.chromium.org'],), ''), | 664 'gerrit.chromium.org'],), ''), |
| 664 ((['git', 'config', 'gerrit.port', '29418'],), ''), | 665 ((['git', 'config', 'gerrit.port', '29418'],), ''), |
| 665 # DownloadHooks(False) | 666 # DownloadHooks(False) |
| 666 ((['git', 'config', 'gerrit.host'],), | 667 ((['git', 'config', 'gerrit.host'],), |
| 667 'gerrit.chromium.org'), | 668 'gerrit.chromium.org'), |
| 668 ((['git', 'config', 'rietveld.server'],), | |
| 669 'gerrit.chromium.org'), | |
| 670 ((['git', 'rev-parse', '--show-cdup'],), ''), | 669 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 671 ((commit_msg_path, os.X_OK,), False), | 670 ((commit_msg_path, os.X_OK,), False), |
| 672 (('https://gerrit.chromium.org/tools/hooks/commit-msg', | 671 (('https://gerrit-review.googlesource.com/tools/hooks/commit-msg', |
| 673 commit_msg_path,), ''), | 672 commit_msg_path,), ''), |
| 673 ((commit_msg_path,), ''), |
| 674 ((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), | 674 ((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), |
| 675 # GetCodereviewSettingsInteractively | 675 # GetCodereviewSettingsInteractively |
| 676 ((['git', 'config', 'rietveld.server'],), | 676 ((['git', 'config', 'rietveld.server'],), |
| 677 'gerrit.chromium.org'), | 677 'gerrit.chromium.org'), |
| 678 (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), | 678 (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), |
| 679 ''), | 679 ''), |
| 680 ((['git', 'config', 'rietveld.cc'],), ''), | 680 ((['git', 'config', 'rietveld.cc'],), ''), |
| 681 (('CC list:',), ''), | 681 (('CC list:',), ''), |
| 682 ((['git', 'config', 'rietveld.private'],), ''), | 682 ((['git', 'config', 'rietveld.private'],), ''), |
| 683 (('Private flag (rietveld only):',), ''), | 683 (('Private flag (rietveld only):',), ''), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 obj = git_cl.ChangeDescription(orig) | 718 obj = git_cl.ChangeDescription(orig) |
| 719 obj.update_reviewers(reviewers) | 719 obj.update_reviewers(reviewers) |
| 720 actual.append(obj.description) | 720 actual.append(obj.description) |
| 721 self.assertEqual(expected, actual) | 721 self.assertEqual(expected, actual) |
| 722 | 722 |
| 723 | 723 |
| 724 if __name__ == '__main__': | 724 if __name__ == '__main__': |
| 725 git_cl.logging.basicConfig( | 725 git_cl.logging.basicConfig( |
| 726 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 726 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 727 unittest.main() | 727 unittest.main() |
| OLD | NEW |