Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: tests/git_cl_test.py

Issue 2376323002: Reland of Add CC_LIST and --cc to Gerrit issues via API to be similar to CCs in Rietveld (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« git_cl.py ('K') | « git_cl.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 ((['git', 'commit-tree', '0123456789abcdef', '-p', 877 ((['git', 'commit-tree', '0123456789abcdef', '-p',
878 'origin/master', '-m', description],), 878 'origin/master', '-m', description],),
879 ref_to_push), 879 ref_to_push),
880 ] 880 ]
881 else: 881 else:
882 ref_to_push = 'HEAD' 882 ref_to_push = 'HEAD'
883 883
884 calls += [ 884 calls += [
885 ((['git', 'rev-list', 885 ((['git', 'rev-list',
886 expected_upstream_ref + '..' + ref_to_push],), ''), 886 expected_upstream_ref + '..' + ref_to_push],), ''),
887 ((['git', 'config', 'rietveld.cc'],), '')
888 ] 887 ]
889 888
890 notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE') 889 notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE')
891 if ref_suffix: 890 if ref_suffix:
892 ref_suffix += ',' + notify_suffix 891 ref_suffix += ',' + notify_suffix
893 else: 892 else:
894 ref_suffix = '%' + notify_suffix 893 ref_suffix = '%' + notify_suffix
895 894
896 # Add cc from watch list.
897 ref_suffix += ',cc=joe@example.com'
898
899 if reviewers: 895 if reviewers:
900 ref_suffix += ',' + ','.join('r=%s' % email 896 ref_suffix += ',' + ','.join('r=%s' % email
901 for email in sorted(reviewers)) 897 for email in sorted(reviewers))
902 calls += [ 898 calls += [
903 ((['git', 'push', 'origin', 899 ((['git', 'push', 'origin',
904 ref_to_push + ':refs/for/refs/heads/master' + ref_suffix],), 900 ref_to_push + ':refs/for/refs/heads/master' + ref_suffix],),
905 ('remote:\n' 901 ('remote:\n'
906 'remote: Processing changes: (\)\n' 902 'remote: Processing changes: (\)\n'
907 'remote: Processing changes: (|)\n' 903 'remote: Processing changes: (|)\n'
908 'remote: Processing changes: (/)\n' 904 'remote: Processing changes: (/)\n'
909 'remote: Processing changes: (-)\n' 905 'remote: Processing changes: (-)\n'
910 'remote: Processing changes: new: 1 (/)\n' 906 'remote: Processing changes: new: 1 (/)\n'
911 'remote: Processing changes: new: 1, done\n' 907 'remote: Processing changes: new: 1, done\n'
912 'remote:\n' 908 'remote:\n'
913 'remote: New Changes:\n' 909 'remote: New Changes:\n'
914 'remote: https://chromium-review.googlesource.com/123456 XXX.\n' 910 'remote: https://chromium-review.googlesource.com/123456 XXX.\n'
915 'remote:\n' 911 'remote:\n'
916 'To https://chromium.googlesource.com/yyy/zzz\n' 912 'To https://chromium.googlesource.com/yyy/zzz\n'
917 ' * [new branch] hhhh -> refs/for/refs/heads/master\n')), 913 ' * [new branch] hhhh -> refs/for/refs/heads/master\n')),
918 ] 914 ]
919 if squash: 915 if squash:
920 calls += [ 916 calls += [
921 ((['git', 'config', 'branch.master.gerritissue', '123456'],), 917 ((['git', 'config', 'branch.master.gerritissue', '123456'],),
922 ''), 918 ''),
923 ((['git', 'config', 'branch.master.gerritserver', 919 ((['git', 'config', 'branch.master.gerritserver',
924 'https://chromium-review.googlesource.com'],), ''), 920 'https://chromium-review.googlesource.com'],), ''),
925 ((['git', 'config', 'branch.master.gerritsquashhash', 921 ((['git', 'config', 'branch.master.gerritsquashhash',
926 'abcdef0123456789'],), ''), 922 'abcdef0123456789'],), ''),
927 ] 923 ]
924 calls += [
925 ((['git', 'config', 'rietveld.cc'],), ''),
926 ((['AddReviewers', 'chromium-review.googlesource.com',
927 123456 if squash else None,
928 ['joe@example.com'], False],), ''),
929 ]
928 calls += cls._git_post_upload_calls() 930 calls += cls._git_post_upload_calls()
929 return calls 931 return calls
930 932
931 def _run_gerrit_upload_test( 933 def _run_gerrit_upload_test(
932 self, 934 self,
933 upload_args, 935 upload_args,
934 description, 936 description,
935 reviewers=None, 937 reviewers=None,
936 squash=True, 938 squash=True,
937 squash_mode=None, 939 squash_mode=None,
(...skipping 13 matching lines...) Expand all
951 953
952 reviewers = reviewers or [] 954 reviewers = reviewers or []
953 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) 955 self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
954 self.mock(git_cl.gerrit_util, 'CookiesAuthenticator', 956 self.mock(git_cl.gerrit_util, 'CookiesAuthenticator',
955 CookiesAuthenticatorMockFactory(same_cookie='same_cred')) 957 CookiesAuthenticatorMockFactory(same_cookie='same_cred'))
956 self.mock(git_cl._GerritChangelistImpl, '_GerritCommitMsgHookCheck', 958 self.mock(git_cl._GerritChangelistImpl, '_GerritCommitMsgHookCheck',
957 lambda _, offer_removal: None) 959 lambda _, offer_removal: None)
958 self.mock(git_cl.gclient_utils, 'RunEditor', 960 self.mock(git_cl.gclient_utils, 'RunEditor',
959 lambda *_, **__: self._mocked_call(['RunEditor'])) 961 lambda *_, **__: self._mocked_call(['RunEditor']))
960 self.mock(git_cl, 'DownloadGerritHook', self._mocked_call) 962 self.mock(git_cl, 'DownloadGerritHook', self._mocked_call)
963 self.mock(git_cl.gerrit_util, 'AddReviewers',
964 lambda h, i, add, is_reviewer: self._mocked_call(
965 ['AddReviewers', h, i, add, is_reviewer]))
961 966
962 self.calls = self._gerrit_base_calls(issue=issue) 967 self.calls = self._gerrit_base_calls(issue=issue)
963 self.calls += self._gerrit_upload_calls( 968 self.calls += self._gerrit_upload_calls(
964 description, reviewers, squash, 969 description, reviewers, squash,
965 squash_mode=squash_mode, 970 squash_mode=squash_mode,
966 expected_upstream_ref=expected_upstream_ref, 971 expected_upstream_ref=expected_upstream_ref,
967 ref_suffix=ref_suffix, notify=notify, 972 ref_suffix=ref_suffix, notify=notify,
968 post_amend_description=post_amend_description, 973 post_amend_description=post_amend_description,
969 issue=issue) 974 issue=issue)
970 # Uncomment when debugging. 975 # Uncomment when debugging.
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 out = StringIO.StringIO() 1965 out = StringIO.StringIO()
1961 self.mock(sys, 'stdout', out) 1966 self.mock(sys, 'stdout', out)
1962 self.assertEqual(0, cl.CMDLand(force=True, bypass_hooks=True, verbose=True)) 1967 self.assertEqual(0, cl.CMDLand(force=True, bypass_hooks=True, verbose=True))
1963 self.assertRegexpMatches(out.getvalue(), 'Issue.*123 has been submitted') 1968 self.assertRegexpMatches(out.getvalue(), 'Issue.*123 has been submitted')
1964 1969
1965 1970
1966 if __name__ == '__main__': 1971 if __name__ == '__main__':
1967 git_cl.logging.basicConfig( 1972 git_cl.logging.basicConfig(
1968 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) 1973 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
1969 unittest.main() 1974 unittest.main()
OLDNEW
« git_cl.py ('K') | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698