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

Side by Side Diff: tests/git_cl_test.py

Issue 2117483002: Implement git cl upload -b BUG --bug=BUG. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix Created 4 years, 5 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 test('ssh://chrome-review.source.com/#/c/123/4/', fail=True) 201 test('ssh://chrome-review.source.com/#/c/123/4/', fail=True)
202 # Rietveld. 202 # Rietveld.
203 test('https://codereview.source.com/123', 203 test('https://codereview.source.com/123',
204 123, None, 'codereview.source.com') 204 123, None, 'codereview.source.com')
205 test('https://codereview.source.com/www123', fail=True) 205 test('https://codereview.source.com/www123', fail=True)
206 # Gerrrit. 206 # Gerrrit.
207 test('https://chrome-review.source.com/c/123/4', 207 test('https://chrome-review.source.com/c/123/4',
208 123, 4, 'chrome-review.source.com') 208 123, 4, 'chrome-review.source.com')
209 test('https://chrome-review.source.com/bad/123/4', fail=True) 209 test('https://chrome-review.source.com/bad/123/4', fail=True)
210 210
211 def test_get_bug_line_values(self):
212 f = lambda p, bugs: list(git_cl._get_bug_line_values(p, bugs))
213 self.assertEqual(f('', ''), [])
214 self.assertEqual(f('', '123,v8:456'), ['123', 'v8:456'])
215 self.assertEqual(f('v8', '456'), ['v8:456'])
216 self.assertEqual(f('v8', 'chromium:123,456'), ['v8:456', 'chromium:123'])
217 # Not nice, but not worth carying.
218 self.assertEqual(f('v8', 'chromium:123,456,v8:123'),
219 ['v8:456', 'chromium:123', 'v8:123'])
220
211 221
212 class TestGitCl(TestCase): 222 class TestGitCl(TestCase):
213 def setUp(self): 223 def setUp(self):
214 super(TestGitCl, self).setUp() 224 super(TestGitCl, self).setUp()
215 self.calls = [] 225 self.calls = []
216 self._calls_done = [] 226 self._calls_done = []
217 self.mock(subprocess2, 'call', self._mocked_call) 227 self.mock(subprocess2, 'call', self._mocked_call)
218 self.mock(subprocess2, 'check_call', self._mocked_call) 228 self.mock(subprocess2, 'check_call', self._mocked_call)
219 self.mock(subprocess2, 'check_output', self._mocked_call) 229 self.mock(subprocess2, 'check_output', self._mocked_call)
220 self.mock(subprocess2, 'communicate', self._mocked_call) 230 self.mock(subprocess2, 'communicate', self._mocked_call)
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 git_cl.main(['upload', '--send-mail']) 691 git_cl.main(['upload', '--send-mail'])
682 self.fail() 692 self.fail()
683 except SystemExit: 693 except SystemExit:
684 self.assertEqual( 694 self.assertEqual(
685 'Using 50% similarity for rename/copy detection. Override with ' 695 'Using 50% similarity for rename/copy detection. Override with '
686 '--similarity.\n', 696 '--similarity.\n',
687 stdout.getvalue()) 697 stdout.getvalue())
688 self.assertEqual( 698 self.assertEqual(
689 'Must specify reviewers to send email.\n', stderr.getvalue()) 699 'Must specify reviewers to send email.\n', stderr.getvalue())
690 700
701 def test_bug_on_cmd(self):
702 self._run_reviewer_test(
703 ['--bug=500658,proj:123'],
704 'desc\n\nBUG=500658\nBUG=proj:123',
705 '# Blah blah comment.\ndesc\n\nBUG=500658\nBUG=proj:1234',
706 'desc\n\nBUG=500658\nBUG=proj:1234',
707 [])
708
691 def test_dcommit(self): 709 def test_dcommit(self):
692 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) 710 self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
693 self.calls = ( 711 self.calls = (
694 self._dcommit_calls_1() + 712 self._dcommit_calls_1() +
695 self._git_sanity_checks('fake_ancestor_sha', 'working') + 713 self._git_sanity_checks('fake_ancestor_sha', 'working') +
696 self._dcommit_calls_normal() + 714 self._dcommit_calls_normal() +
697 self._dcommit_calls_3()) 715 self._dcommit_calls_3())
698 git_cl.main(['dcommit']) 716 git_cl.main(['dcommit'])
699 717
700 def test_dcommit_bypass_hooks(self): 718 def test_dcommit_bypass_hooks(self):
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), 1713 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],),
1696 ''), 1714 ''),
1697 ] 1715 ]
1698 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) 1716 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True)
1699 1717
1700 1718
1701 if __name__ == '__main__': 1719 if __name__ == '__main__':
1702 git_cl.logging.basicConfig( 1720 git_cl.logging.basicConfig(
1703 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) 1721 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
1704 unittest.main() 1722 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