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 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 git_cl.main(['status', '--issue', '1']) | |
tandrii(chromium)
2016/08/17 20:16:32
add assert 0 :)
iannucci
2016/08/17 20:20:36
done
| |
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 git_cl.main(['status', '--issue', '1', '--rietveld']) | |
tandrii(chromium)
2016/08/17 20:16:32
ditto
iannucci
2016/08/17 20:20:36
done
| |
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_StatusFieldOverrideIssueMissingArgs(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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1751 ((['exists', '/abs/git_repo_root/.git/hooks/commit-msg'],), True), | 1787 ((['exists', '/abs/git_repo_root/.git/hooks/commit-msg'],), True), |
1752 ((['FileRead', '/abs/git_repo_root/.git/hooks/commit-msg'],), | 1788 ((['FileRead', '/abs/git_repo_root/.git/hooks/commit-msg'],), |
1753 '...\n# From Gerrit Code Review\n...\nadd_ChangeId()\n'), | 1789 '...\n# From Gerrit Code Review\n...\nadd_ChangeId()\n'), |
1754 (('Do you want to remove it now? [Yes/No]',), 'Yes'), | 1790 (('Do you want to remove it now? [Yes/No]',), 'Yes'), |
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 |
1797 | |
tandrii(chromium)
2016/08/17 20:16:32
delete
iannucci
2016/08/17 20:20:36
done in later patchset :)
| |
1761 if __name__ == '__main__': | 1798 if __name__ == '__main__': |
1762 git_cl.logging.basicConfig( | 1799 git_cl.logging.basicConfig( |
1763 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1800 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
1764 unittest.main() | 1801 unittest.main() |
OLD | NEW |