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 20 matching lines...) Expand all Loading... |
31 class ChangelistMock(object): | 31 class ChangelistMock(object): |
32 # A class variable so we can access it when we don't have access to the | 32 # A class variable so we can access it when we don't have access to the |
33 # instance that's being set. | 33 # instance that's being set. |
34 desc = "" | 34 desc = "" |
35 def __init__(self, **kwargs): | 35 def __init__(self, **kwargs): |
36 pass | 36 pass |
37 def GetIssue(self): | 37 def GetIssue(self): |
38 return 1 | 38 return 1 |
39 def GetDescription(self): | 39 def GetDescription(self): |
40 return ChangelistMock.desc | 40 return ChangelistMock.desc |
41 def UpdateDescription(self, desc): | 41 def UpdateDescription(self, desc, force=False): |
42 ChangelistMock.desc = desc | 42 ChangelistMock.desc = desc |
43 | 43 |
44 | 44 |
45 class PresubmitMock(object): | 45 class PresubmitMock(object): |
46 def __init__(self, *args, **kwargs): | 46 def __init__(self, *args, **kwargs): |
47 self.reviewers = [] | 47 self.reviewers = [] |
48 @staticmethod | 48 @staticmethod |
49 def should_continue(): | 49 def should_continue(): |
50 return True | 50 return True |
51 | 51 |
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 '# Enter a description of the change.\n' | 1657 '# Enter a description of the change.\n' |
1658 '# This will be displayed on the codereview site.\n' | 1658 '# This will be displayed on the codereview site.\n' |
1659 '# The first line will also be used as the subject of the review.\n' | 1659 '# The first line will also be used as the subject of the review.\n' |
1660 '#--------------------This line is 72 characters long' | 1660 '#--------------------This line is 72 characters long' |
1661 '--------------------\n' | 1661 '--------------------\n' |
1662 'Some.\n\nBUG=\n\nChange-Id: xxx', | 1662 'Some.\n\nBUG=\n\nChange-Id: xxx', |
1663 desc) | 1663 desc) |
1664 # Simulate user changing something. | 1664 # Simulate user changing something. |
1665 return 'Some.\n\nBUG=123\n\nChange-Id: xxx' | 1665 return 'Some.\n\nBUG=123\n\nChange-Id: xxx' |
1666 | 1666 |
1667 def UpdateDescriptionRemote(_, desc): | 1667 def UpdateDescriptionRemote(_, desc, force=False): |
1668 self.assertEquals(desc, 'Some.\n\nBUG=123\n\nChange-Id: xxx') | 1668 self.assertEquals(desc, 'Some.\n\nBUG=123\n\nChange-Id: xxx') |
1669 | 1669 |
1670 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | 1670 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
1671 self.mock(git_cl.Changelist, 'GetDescription', | 1671 self.mock(git_cl.Changelist, 'GetDescription', |
1672 lambda *args: current_desc) | 1672 lambda *args: current_desc) |
1673 self.mock(git_cl._GerritChangelistImpl, 'UpdateDescriptionRemote', | 1673 self.mock(git_cl._GerritChangelistImpl, 'UpdateDescriptionRemote', |
1674 UpdateDescriptionRemote) | 1674 UpdateDescriptionRemote) |
1675 self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor) | 1675 self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor) |
1676 | 1676 |
1677 self.calls = [ | 1677 self.calls = [ |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 'current_revision': 'deadbeaf', | 1957 'current_revision': 'deadbeaf', |
1958 } | 1958 } |
1959 cl._codereview_impl.SubmitIssue = lambda wait_for_merge: None | 1959 cl._codereview_impl.SubmitIssue = lambda wait_for_merge: None |
1960 self.assertEqual(0, cl.CMDLand(force=True, bypass_hooks=True, verbose=True)) | 1960 self.assertEqual(0, cl.CMDLand(force=True, bypass_hooks=True, verbose=True)) |
1961 | 1961 |
1962 | 1962 |
1963 if __name__ == '__main__': | 1963 if __name__ == '__main__': |
1964 git_cl.logging.basicConfig( | 1964 git_cl.logging.basicConfig( |
1965 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1965 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
1966 unittest.main() | 1966 unittest.main() |
OLD | NEW |