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 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 | 1490 |
1491 self.mock(git_cl, 'Changelist', ChangelistMock) | 1491 self.mock(git_cl, 'Changelist', ChangelistMock) |
1492 ChangelistMock.desc = 'foo\n' | 1492 ChangelistMock.desc = 'foo\n' |
1493 | 1493 |
1494 self.assertEqual(0, git_cl.main(['description', '-d'])) | 1494 self.assertEqual(0, git_cl.main(['description', '-d'])) |
1495 self.assertEqual('foo\n', out.getvalue()) | 1495 self.assertEqual('foo\n', out.getvalue()) |
1496 | 1496 |
1497 def test_description_rietveld(self): | 1497 def test_description_rietveld(self): |
1498 out = StringIO.StringIO() | 1498 out = StringIO.StringIO() |
1499 self.mock(git_cl.sys, 'stdout', out) | 1499 self.mock(git_cl.sys, 'stdout', out) |
1500 self.mock(git_cl.Changelist, 'GetDescription', | 1500 self.mock(git_cl.Changelist, 'GetDescription', lambda *args: 'foobar') |
1501 lambda *args: 'foobar') | |
1502 | 1501 |
1503 self.calls = [ | |
1504 ((['git', 'config', 'rietveld.autoupdate'],), ''), | |
1505 ((['git', 'config', 'rietveld.server'],), ''), | |
1506 ((['git', 'config', 'rietveld.server'],), ''), | |
1507 ] | |
1508 self.assertEqual(0, git_cl.main([ | 1502 self.assertEqual(0, git_cl.main([ |
1509 'description', 'https://code.review.org/123123', '-d', '--rietveld'])) | 1503 'description', 'https://code.review.org/123123', '-d', '--rietveld'])) |
1510 self.assertEqual('foobar\n', out.getvalue()) | 1504 self.assertEqual('foobar\n', out.getvalue()) |
1511 | 1505 |
1512 def test_description_gerrit(self): | 1506 def test_description_gerrit(self): |
1513 out = StringIO.StringIO() | 1507 out = StringIO.StringIO() |
1514 self.mock(git_cl.sys, 'stdout', out) | 1508 self.mock(git_cl.sys, 'stdout', out) |
1515 self.mock(git_cl.Changelist, 'GetDescription', | 1509 self.mock(git_cl.Changelist, 'GetDescription', lambda *args: 'foobar') |
1516 lambda *args: 'foobar') | |
1517 | 1510 |
1518 self.assertEqual(0, git_cl.main([ | 1511 self.assertEqual(0, git_cl.main([ |
1519 'description', 'https://code.review.org/123123', '-d', '--gerrit'])) | 1512 'description', 'https://code.review.org/123123', '-d', '--gerrit'])) |
1520 self.assertEqual('foobar\n', out.getvalue()) | 1513 self.assertEqual('foobar\n', out.getvalue()) |
1521 | 1514 |
1522 def test_description_set_raw(self): | 1515 def test_description_set_raw(self): |
1523 out = StringIO.StringIO() | 1516 out = StringIO.StringIO() |
1524 self.mock(git_cl.sys, 'stdout', out) | 1517 self.mock(git_cl.sys, 'stdout', out) |
1525 | 1518 |
1526 self.mock(git_cl, 'Changelist', ChangelistMock) | 1519 self.mock(git_cl, 'Changelist', ChangelistMock) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), | 1688 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), |
1696 ''), | 1689 ''), |
1697 ] | 1690 ] |
1698 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) | 1691 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) |
1699 | 1692 |
1700 | 1693 |
1701 if __name__ == '__main__': | 1694 if __name__ == '__main__': |
1702 git_cl.logging.basicConfig( | 1695 git_cl.logging.basicConfig( |
1703 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1696 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
1704 unittest.main() | 1697 unittest.main() |
OLD | NEW |