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

Side by Side Diff: tests/git_cl_test.py

Issue 2250323003: Add --issue flag to git cl status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: add more asserts Created 4 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « 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 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1525
1526 def test_description_rietveld(self): 1526 def test_description_rietveld(self):
1527 out = StringIO.StringIO() 1527 out = StringIO.StringIO()
1528 self.mock(git_cl.sys, 'stdout', out) 1528 self.mock(git_cl.sys, 'stdout', out)
1529 self.mock(git_cl.Changelist, 'GetDescription', lambda *args: 'foobar') 1529 self.mock(git_cl.Changelist, 'GetDescription', lambda *args: 'foobar')
1530 1530
1531 self.assertEqual(0, git_cl.main([ 1531 self.assertEqual(0, git_cl.main([
1532 'description', 'https://code.review.org/123123', '-d', '--rietveld'])) 1532 'description', 'https://code.review.org/123123', '-d', '--rietveld']))
1533 self.assertEqual('foobar\n', out.getvalue()) 1533 self.assertEqual('foobar\n', out.getvalue())
1534 1534
1535 def test_StatusFieldOverrideIssueMissingArgs(self):
1536 out = StringIO.StringIO()
1537 self.mock(git_cl.sys, 'stderr', out)
1538
1539 try:
1540 self.assertEqual(git_cl.main(['status', '--issue', '1']), 0)
1541 except SystemExit as ex:
1542 self.assertEqual(ex.code, 2)
1543 self.assertRegexpMatches(out.getvalue(), r'--issue may only be specified')
1544
1545 out = StringIO.StringIO()
1546 self.mock(git_cl.sys, 'stderr', out)
1547
1548 try:
1549 self.assertEqual(git_cl.main(['status', '--issue', '1', '--rietveld']), 0)
1550 except SystemExit as ex:
1551 self.assertEqual(ex.code, 2)
1552 self.assertRegexpMatches(out.getvalue(), r'--issue may only be specified')
1553
1554 def test_StatusFieldOverrideIssue(self):
1555 out = StringIO.StringIO()
1556 self.mock(git_cl.sys, 'stdout', out)
1557
1558 def assertIssue(cl_self, *_args):
1559 self.assertEquals(cl_self.issue, 1)
1560 return 'foobar'
1561
1562 self.mock(git_cl.Changelist, 'GetDescription', assertIssue)
1563 self.calls = [
1564 ((['git', 'config', 'rietveld.autoupdate'],), ''),
1565 ((['git', 'config', 'rietveld.server'],), ''),
1566 ((['git', 'config', 'rietveld.server'],), ''),
1567 ]
1568 git_cl.main(['status', '--issue', '1', '--rietveld', '--field', 'desc'])
1569 self.assertEqual(out.getvalue(), 'foobar\n')
1570
1535 def test_description_gerrit(self): 1571 def test_description_gerrit(self):
1536 out = StringIO.StringIO() 1572 out = StringIO.StringIO()
1537 self.mock(git_cl.sys, 'stdout', out) 1573 self.mock(git_cl.sys, 'stdout', out)
1538 self.mock(git_cl.Changelist, 'GetDescription', lambda *args: 'foobar') 1574 self.mock(git_cl.Changelist, 'GetDescription', lambda *args: 'foobar')
1539 1575
1540 self.assertEqual(0, git_cl.main([ 1576 self.assertEqual(0, git_cl.main([
1541 'description', 'https://code.review.org/123123', '-d', '--gerrit'])) 1577 'description', 'https://code.review.org/123123', '-d', '--gerrit']))
1542 self.assertEqual('foobar\n', out.getvalue()) 1578 self.assertEqual('foobar\n', out.getvalue())
1543 1579
1544 def test_description_set_raw(self): 1580 def test_description_set_raw(self):
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), 1791 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],),
1756 ''), 1792 ''),
1757 ] 1793 ]
1758 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) 1794 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True)
1759 1795
1760 1796
1761 if __name__ == '__main__': 1797 if __name__ == '__main__':
1762 git_cl.logging.basicConfig( 1798 git_cl.logging.basicConfig(
1763 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) 1799 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
1764 unittest.main() 1800 unittest.main()
OLDNEW
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698