@ -210,7 +210,7 @@ class PresubmitUnittest(PresubmitTestsBase):
files = files )
files = files )
change = presubmit . GclChange ( ci )
change = presubmit . GclChange ( ci )
self . failUnless ( change . Chang e( ) == ' mychange ' )
self . failUnless ( change . Nam e( ) == ' mychange ' )
self . failUnless ( change . DescriptionText ( ) ==
self . failUnless ( change . DescriptionText ( ) ==
' Hello there \n this is a change \n and some more regular text ' )
' Hello there \n this is a change \n and some more regular text ' )
self . failUnless ( change . FullDescriptionText ( ) ==
self . failUnless ( change . FullDescriptionText ( ) ==
@ -481,24 +481,31 @@ def CheckChangeOnCommit(input_api, output_api):
def testTags ( self ) :
def testTags ( self ) :
DEFAULT_SCRIPT = """
DEFAULT_SCRIPT = """
def CheckChangeOnUpload ( input_api , output_api ) :
def CheckChangeOnUpload ( input_api , output_api ) :
if input_api . change . tags [ ' BUG ' ] != ' boo ' :
if input_api . change . tags [ ' BUG ' ] != ' boo ' :
return [ output_api . PresubmitError ( ' Tag parsing failed. 1 ' ) ]
return [ output_api . PresubmitError ( ' Tag parsing failed. 1 ' ) ]
if input_api . change . tags [ ' STORY ' ] != ' http://tracker.com/42 ' :
if input_api . change . tags [ ' STORY ' ] != ' http://tracker.com/42 ' :
return [ output_api . PresubmitError ( ' Tag parsing failed. 2 ' ) ]
return [ output_api . PresubmitError ( ' Tag parsing failed. 2 ' ) ]
if input_api . change . BUG != ' boo ' :
if input_api . change . BUG != ' boo ' :
return [ output_api . PresubmitError ( ' Tag parsing failed. 6 ' ) ]
return [ output_api . PresubmitError ( ' Tag parsing failed. 6 ' ) ]
if input_api . change . STORY != ' http://tracker.com/42 ' :
if input_api . change . STORY != ' http://tracker.com/42 ' :
return [ output_api . PresubmitError ( ' Tag parsing failed. 7 ' ) ]
return [ output_api . PresubmitError ( ' Tag parsing failed. 7 ' ) ]
if ' TEST ' in input_api . change . tags :
try :
return [ output_api . PresubmitError ( ' Tag parsing failed. 3 ' ) ]
y = False
if input_api . change . DescriptionText ( ) != ' Blah Blah ' :
x = input_api . change . invalid
return [ output_api . PresubmitError ( ' Tag parsing failed. 4 ' +
except AttributeError :
input_api . change . DescriptionText ( ) ) ]
y = True
if ( input_api . change . FullDescriptionText ( ) !=
if not y :
' Blah Blah \\ n \\ nSTORY=http://tracker.com/42 \\ nBUG=boo \\ n ' ) :
return [ output_api . PresubmitError ( ' Tag parsing failed. 8 ' ) ]
return [ output_api . PresubmitError ( ' Tag parsing failed. 5 ' +
if ' TEST ' in input_api . change . tags :
input_api . change . FullDescriptionText ( ) ) ]
return [ output_api . PresubmitError ( ' Tag parsing failed. 3 ' ) ]
return [ output_api . PresubmitNotifyResult ( input_api . change . tags [ ' STORY ' ] ) ]
if input_api . change . DescriptionText ( ) != ' Blah Blah ' :
return [ output_api . PresubmitError ( ' Tag parsing failed. 4 ' +
input_api . change . DescriptionText ( ) ) ]
if ( input_api . change . FullDescriptionText ( ) !=
' Blah Blah \\ n \\ nSTORY=http://tracker.com/42 \\ nBUG=boo \\ n ' ) :
return [ output_api . PresubmitError ( ' Tag parsing failed. 5 ' +
input_api . change . FullDescriptionText ( ) ) ]
return [ output_api . PresubmitNotifyResult ( input_api . change . tags [ ' STORY ' ] ) ]
def CheckChangeOnCommit ( input_api , output_api ) :
def CheckChangeOnCommit ( input_api , output_api ) :
raise Exception ( " Test error " )
raise Exception ( " Test error " )
"""
"""
@ -907,8 +914,8 @@ class GclChangeUnittest(PresubmitTestsBase):
def testMembersChanged ( self ) :
def testMembersChanged ( self ) :
self . mox . ReplayAll ( )
self . mox . ReplayAll ( )
members = [
members = [
' AbsoluteLocalPaths ' , ' AffectedFiles ' , ' AffectedTextFiles ' , ' Change ' ,
' AbsoluteLocalPaths ' , ' AffectedFiles ' , ' AffectedTextFiles ' ,
' DescriptionText ' , ' FullDescriptionText ' , ' LocalPaths ' ,
' DescriptionText ' , ' FullDescriptionText ' , ' LocalPaths ' , ' Name ' ,
' RepositoryRoot ' , ' RightHandSideLines ' , ' ServerPaths ' ,
' RepositoryRoot ' , ' RightHandSideLines ' , ' ServerPaths ' ,
' issue ' , ' patchset ' , ' tags ' ,
' issue ' , ' patchset ' , ' tags ' ,
]
]