#NEWLINE# @ pytest . mark . parametrize ( 'autorebuild, submitter' , [ ( True , 'John Smith <jsmith@foobar.com>' ) , ( False , 'John Smith <jsmith@foobar.com>' ) , ( True , None ) , ( False , None ) ] ) #NEWLINE# def test_render_mail( self , autorebuild , submitter ) : #NEWLINE# #INDENT# class WF ( object ) : #NEWLINE# #INDENT# image = ImageName . parse ( 'foo/bar:baz' ) #NEWLINE# openshift_build_selflink = '/builds/blablabla' #NEWLINE# #UNINDENT# kwargs = { #NEWLINE# #INDENT# 'url' : 'https://something.com' , #NEWLINE# #UNINDENT# } #NEWLINE# if submitter : #NEWLINE# #INDENT# kwargs [ 'submitter' ] = submitter #NEWLINE# #UNINDENT# p = SendMailPlugin ( None , WF ( ) , ** kwargs ) #NEWLINE# ( subject , body ) = p . _render_mail ( autorebuild , False , False ) #NEWLINE# exp_subject = 'Image foo/bar:baz; Status failed; Submitted by ' #NEWLINE# exp_body = [ 'Image: foo/bar:baz' , 'Status: failed' , 'Submitted by: ' , 'Logs: https://something.com/builds/blablabla/log' ] #NEWLINE# if autorebuild : #NEWLINE# #INDENT# exp_subject += '<autorebuild>' #NEWLINE# exp_body [ 2 ] += '<autorebuild>' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if submitter : #NEWLINE# #INDENT# exp_subject += submitter #NEWLINE# exp_body [ 2 ] += submitter #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exp_subject += 'unknown' #NEWLINE# exp_body [ 2 ] += 'unknown' #NEWLINE# #UNINDENT# #UNINDENT# assert ( subject == exp_subject ) #NEWLINE# assert ( body == '\n' . join ( exp_body ) )