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

Side by Side Diff: tests/git_cl_test.py

Issue 2318903002: Prompt to delete pending edits before changing the Gerrit CL description. (Closed)
Patch Set: CL comments Created 4 years, 3 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
« 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 20 matching lines...) Expand all
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
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
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()
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