| 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 def GetIssue(self): | 739 def GetIssue(self): |
| 740 return '123' | 740 return '123' |
| 741 def GetPatchset(self): | 741 def GetPatchset(self): |
| 742 return '1001' | 742 return '1001' |
| 743 | 743 |
| 744 ret = git_cl.upload_branch_deps(MockChangelist(), []) | 744 ret = git_cl.upload_branch_deps(MockChangelist(), []) |
| 745 # CMDupload should have been called 5 times because of 5 dependent branches. | 745 # CMDupload should have been called 5 times because of 5 dependent branches. |
| 746 self.assertEquals(5, record_calls.times_called) | 746 self.assertEquals(5, record_calls.times_called) |
| 747 self.assertEquals(0, ret) | 747 self.assertEquals(0, ret) |
| 748 | 748 |
| 749 def test_gerrit_change_id(self): |
| 750 self.calls = [ |
| 751 ((['git', 'write-tree'], ), |
| 752 'hashtree'), |
| 753 ((['git', 'rev-parse', 'HEAD~0'], ), |
| 754 'branch-parent'), |
| 755 ((['git', 'var', 'GIT_AUTHOR_IDENT'], ), |
| 756 'A B <a@b.org> 1456848326 +0100'), |
| 757 ((['git', 'var', 'GIT_COMMITTER_IDENT'], ), |
| 758 'C D <c@d.org> 1456858326 +0100'), |
| 759 ((['git', 'hash-object', '-t', 'commit', '--stdin'], ), |
| 760 'hashchange'), |
| 761 ] |
| 762 change_id = git_cl.GenerateGerritChangeId('line1\nline2\n') |
| 763 self.assertEqual(change_id, 'Ihashchange') |
| 764 |
| 749 def test_config_gerrit_download_hook(self): | 765 def test_config_gerrit_download_hook(self): |
| 750 self.mock(git_cl, 'FindCodereviewSettingsFile', CodereviewSettingsFileMock) | 766 self.mock(git_cl, 'FindCodereviewSettingsFile', CodereviewSettingsFileMock) |
| 751 def ParseCodereviewSettingsContent(content): | 767 def ParseCodereviewSettingsContent(content): |
| 752 keyvals = {} | 768 keyvals = {} |
| 753 keyvals['CODE_REVIEW_SERVER'] = 'gerrit.chromium.org' | 769 keyvals['CODE_REVIEW_SERVER'] = 'gerrit.chromium.org' |
| 754 keyvals['GERRIT_HOST'] = 'True' | 770 keyvals['GERRIT_HOST'] = 'True' |
| 755 return keyvals | 771 return keyvals |
| 756 self.mock(git_cl.gclient_utils, 'ParseCodereviewSettingsContent', | 772 self.mock(git_cl.gclient_utils, 'ParseCodereviewSettingsContent', |
| 757 ParseCodereviewSettingsContent) | 773 ParseCodereviewSettingsContent) |
| 758 self.mock(git_cl.os, 'access', self._mocked_call) | 774 self.mock(git_cl.os, 'access', self._mocked_call) |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 self.calls += [ | 970 self.calls += [ |
| 955 ((['git', 'apply', '--index', '-p0', '--3way'],), '', | 971 ((['git', 'apply', '--index', '-p0', '--3way'],), '', |
| 956 subprocess2.CalledProcessError(1, '', '', '', '')), | 972 subprocess2.CalledProcessError(1, '', '', '', '')), |
| 957 ] | 973 ] |
| 958 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) | 974 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) |
| 959 | 975 |
| 960 if __name__ == '__main__': | 976 if __name__ == '__main__': |
| 961 git_cl.logging.basicConfig( | 977 git_cl.logging.basicConfig( |
| 962 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 978 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 963 unittest.main() | 979 unittest.main() |
| OLD | NEW |