@ -2570,7 +2570,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
def AssertOwnersWorks ( self , tbr = False , issue = ' 1 ' , approvers = None ,
def AssertOwnersWorks ( self , tbr = False , issue = ' 1 ' , approvers = None ,
reviewers = None , is_committing = True , rietveld_response = None ,
reviewers = None , is_committing = True , rietveld_response = None ,
uncovered_files = None , expected_output = ' ' ,
uncovered_files = None , expected_output = ' ' ,
manually_specified_reviewers = None ):
manually_specified_reviewers = None , cq_dry_run = False ):
if approvers is None :
if approvers is None :
# The set of people who lgtm'ed a change.
# The set of people who lgtm'ed a change.
approvers = set ( )
approvers = set ( )
@ -2598,6 +2598,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
input_api . tbr = tbr
input_api . tbr = tbr
if not is_committing or ( not tbr and issue ) :
if not is_committing or ( not tbr and issue ) :
if not cq_dry_run :
affected_file . LocalPath ( ) . AndReturn ( ' foo/xyz.cc ' )
affected_file . LocalPath ( ) . AndReturn ( ' foo/xyz.cc ' )
change . AffectedFiles ( file_filter = None ) . AndReturn ( [ affected_file ] )
change . AffectedFiles ( file_filter = None ) . AndReturn ( [ affected_file ] )
if issue and not rietveld_response :
if issue and not rietveld_response :
@ -2612,9 +2613,14 @@ class CannedChecksUnittest(PresubmitTestsBase):
if is_committing :
if is_committing :
people = approvers
people = approvers
if issue :
input_api . rietveld . get_issue_properties (
issue = int ( input_api . change . issue ) , messages = None ) . AndReturn (
rietveld_response )
else :
else :
people = reviewers
people = reviewers
if not cq_dry_run :
if issue :
if issue :
input_api . rietveld . get_issue_properties (
input_api . rietveld . get_issue_properties (
issue = int ( input_api . change . issue ) , messages = True ) . AndReturn (
issue = int ( input_api . change . issue ) , messages = True ) . AndReturn (
@ -2635,6 +2641,23 @@ class CannedChecksUnittest(PresubmitTestsBase):
results [ 0 ] . handle ( output )
results [ 0 ] . handle ( output )
self . assertEquals ( output . getvalue ( ) , expected_output )
self . assertEquals ( output . getvalue ( ) , expected_output )
def testCannedCheckOwners_DryRun ( self ) :
response = {
" owner_email " : " john@example.com " ,
" cq_dry_run " : True ,
" reviewers " : [ " ben@example.com " ] ,
}
self . AssertOwnersWorks ( approvers = set ( ) ,
cq_dry_run = True ,
rietveld_response = response ,
reviewers = set ( [ " ben@example.com " ] ) ,
expected_output = ' This is a CQ dry run, skipping OWNERS check \n ' )
self . AssertOwnersWorks ( approvers = set ( [ ' ben@example.com ' ] ) ,
is_committing = False ,
rietveld_response = response ,
expected_output = ' ' )
def testCannedCheckOwners_Approved ( self ) :
def testCannedCheckOwners_Approved ( self ) :
response = {
response = {
" owner_email " : " john@example.com " ,
" owner_email " : " john@example.com " ,