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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 ''), | 171 ''), |
172 ((['git', 'log', '--pretty=format:%s%n%n%b', | 172 ((['git', 'log', '--pretty=format:%s%n%n%b', |
173 'fake_ancestor_sha...'],), | 173 'fake_ancestor_sha...'],), |
174 'foo'), | 174 'foo'), |
175 ((['git', 'config', 'user.email'],), 'me@example.com'), | 175 ((['git', 'config', 'user.email'],), 'me@example.com'), |
176 stat_call, | 176 stat_call, |
177 ((['git', 'config', 'gerrit.host'],), ''), | 177 ((['git', 'config', 'gerrit.host'],), ''), |
178 ((['git', 'log', '--pretty=format:%s\n\n%b', | 178 ((['git', 'log', '--pretty=format:%s\n\n%b', |
179 'fake_ancestor_sha..HEAD'],), | 179 'fake_ancestor_sha..HEAD'],), |
180 'desc\n'), | 180 'desc\n'), |
| 181 ((['git', 'config', 'rietveld.bug-prefix'],), ''), |
181 ] | 182 ] |
182 | 183 |
183 @classmethod | 184 @classmethod |
184 def _git_upload_no_rev_calls(cls): | 185 def _git_upload_no_rev_calls(cls): |
185 return [ | 186 return [ |
186 ((['git', 'config', 'core.editor'],), ''), | 187 ((['git', 'config', 'core.editor'],), ''), |
187 ] | 188 ] |
188 | 189 |
189 @classmethod | 190 @classmethod |
190 def _git_upload_calls(cls, private): | 191 def _git_upload_calls(cls, private): |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 ''), | 664 ''), |
664 ((['git', 'config', 'rietveld.server', | 665 ((['git', 'config', 'rietveld.server', |
665 'gerrit.chromium.org'],), ''), | 666 'gerrit.chromium.org'],), ''), |
666 ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''), | 667 ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''), |
667 ((['git', 'config', '--unset-all', | 668 ((['git', 'config', '--unset-all', |
668 'rietveld.private'],), ''), | 669 'rietveld.private'],), ''), |
669 ((['git', 'config', '--unset-all', | 670 ((['git', 'config', '--unset-all', |
670 'rietveld.tree-status-url'],), ''), | 671 'rietveld.tree-status-url'],), ''), |
671 ((['git', 'config', '--unset-all', | 672 ((['git', 'config', '--unset-all', |
672 'rietveld.viewvc-url'],), ''), | 673 'rietveld.viewvc-url'],), ''), |
| 674 ((['git', 'config', '--unset-all', |
| 675 'rietveld.bug-prefix'],), ''), |
673 ((['git', 'config', 'gerrit.host', | 676 ((['git', 'config', 'gerrit.host', |
674 'gerrit.chromium.org'],), ''), | 677 'gerrit.chromium.org'],), ''), |
675 # DownloadHooks(False) | 678 # DownloadHooks(False) |
676 ((['git', 'config', 'gerrit.host'],), | 679 ((['git', 'config', 'gerrit.host'],), |
677 'gerrit.chromium.org'), | 680 'gerrit.chromium.org'), |
678 ((['git', 'rev-parse', '--show-cdup'],), ''), | 681 ((['git', 'rev-parse', '--show-cdup'],), ''), |
679 ((commit_msg_path, os.X_OK,), False), | 682 ((commit_msg_path, os.X_OK,), False), |
680 (('https://gerrit-review.googlesource.com/tools/hooks/commit-msg', | 683 (('https://gerrit-review.googlesource.com/tools/hooks/commit-msg', |
681 commit_msg_path,), ''), | 684 commit_msg_path,), ''), |
682 ((commit_msg_path,), True), | 685 ((commit_msg_path,), True), |
683 ((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), | 686 ((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), |
684 # GetCodereviewSettingsInteractively | 687 # GetCodereviewSettingsInteractively |
685 ((['git', 'config', 'rietveld.server'],), | 688 ((['git', 'config', 'rietveld.server'],), |
686 'gerrit.chromium.org'), | 689 'gerrit.chromium.org'), |
687 (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), | 690 (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), |
688 ''), | 691 ''), |
689 ((['git', 'config', 'rietveld.cc'],), ''), | 692 ((['git', 'config', 'rietveld.cc'],), ''), |
690 (('CC list:',), ''), | 693 (('CC list:',), ''), |
691 ((['git', 'config', 'rietveld.private'],), ''), | 694 ((['git', 'config', 'rietveld.private'],), ''), |
692 (('Private flag (rietveld only):',), ''), | 695 (('Private flag (rietveld only):',), ''), |
693 ((['git', 'config', 'rietveld.tree-status-url'],), ''), | 696 ((['git', 'config', 'rietveld.tree-status-url'],), ''), |
694 (('Tree status URL:',), ''), | 697 (('Tree status URL:',), ''), |
695 ((['git', 'config', 'rietveld.viewvc-url'],), ''), | 698 ((['git', 'config', 'rietveld.viewvc-url'],), ''), |
696 (('ViewVC URL:',), ''), | 699 (('ViewVC URL:',), ''), |
697 # DownloadHooks(True) | 700 # DownloadHooks(True) |
| 701 ((['git', 'config', 'rietveld.bug-prefix'],), ''), |
| 702 (('Bug Prefix:',), ''), |
698 ((commit_msg_path, os.X_OK,), True), | 703 ((commit_msg_path, os.X_OK,), True), |
699 ] | 704 ] |
700 git_cl.main(['config']) | 705 git_cl.main(['config']) |
701 | 706 |
702 def test_update_reviewers(self): | 707 def test_update_reviewers(self): |
703 data = [ | 708 data = [ |
704 ('foo', [], 'foo'), | 709 ('foo', [], 'foo'), |
705 ('foo\nR=xx', [], 'foo\nR=xx'), | 710 ('foo\nR=xx', [], 'foo\nR=xx'), |
706 ('foo\nTBR=xx', [], 'foo\nTBR=xx'), | 711 ('foo\nTBR=xx', [], 'foo\nTBR=xx'), |
707 ('foo', ['a@c'], 'foo\n\nR=a@c'), | 712 ('foo', ['a@c'], 'foo\n\nR=a@c'), |
(...skipping 19 matching lines...) Expand all Loading... |
727 obj = git_cl.ChangeDescription(orig) | 732 obj = git_cl.ChangeDescription(orig) |
728 obj.update_reviewers(reviewers) | 733 obj.update_reviewers(reviewers) |
729 actual.append(obj.description) | 734 actual.append(obj.description) |
730 self.assertEqual(expected, actual) | 735 self.assertEqual(expected, actual) |
731 | 736 |
732 | 737 |
733 if __name__ == '__main__': | 738 if __name__ == '__main__': |
734 git_cl.logging.basicConfig( | 739 git_cl.logging.basicConfig( |
735 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 740 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
736 unittest.main() | 741 unittest.main() |
OLD | NEW |