#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# patcher = patch ( 'django_comments_xtd.views.send_mail' ) #NEWLINE# self . mock_mailer = patcher . start ( ) #NEWLINE# self . article = Article . objects . create ( title = 'September' , slug = 'september' , body = "John's September" ) #NEWLINE# self . form = django_comments . get_form ( ) ( self . article ) #NEWLINE# data = { #NEWLINE# #INDENT# 'name' : 'Bob' , #NEWLINE# 'email' : 'bob@example.com' , #NEWLINE# 'followup' : True , #NEWLINE# 'reply_to' : 0 , #NEWLINE# 'level' : 1 , #NEWLINE# 'order' : 1 , #NEWLINE# 'comment' : 'Nice September you had...' , #NEWLINE# #UNINDENT# } #NEWLINE# data . update ( self . form . initial ) #NEWLINE# response = self . client . post ( reverse ( 'comments-post-comment' ) , data = data ) #NEWLINE# self . assert_ ( ( self . mock_mailer . call_count == 1 ) ) #NEWLINE# bobkey = str ( re . search ( 'http://.+/confirm/(?P<key>[\\S]+)' , self . mock_mailer . call_args [ 0 ] [ 1 ] ) . group ( 'key' ) ) #NEWLINE# self . get_confirm_comment_url ( bobkey ) #NEWLINE# data = { #NEWLINE# #INDENT# 'name' : 'Alice' , #NEWLINE# 'email' : 'alice@example.com' , #NEWLINE# 'followup' : True , #NEWLINE# 'reply_to' : 1 , #NEWLINE# 'level' : 1 , #NEWLINE# 'order' : 1 , #NEWLINE# 'comment' : 'Yeah, great photos' , #NEWLINE# #UNINDENT# } #NEWLINE# data . update ( self . form . initial ) #NEWLINE# response = self . client . post ( reverse ( 'comments-post-comment' ) , data = data ) #NEWLINE# self . assert_ ( ( self . mock_mailer . call_count == 2 ) ) #NEWLINE# alicekey = str ( re . search ( 'http://.+/confirm/(?P<key>[\\S]+)' , self . mock_mailer . call_args [ 0 ] [ 1 ] ) . group ( 'key' ) ) #NEWLINE# self . get_confirm_comment_url ( alicekey ) #NEWLINE# self . assert_ ( ( self . mock_mailer . call_count == 3 ) ) #NEWLINE# self . bobs_mutekey = str ( re . search ( 'http://.+/mute/(?P<key>[\\S]+)' , self . mock_mailer . call_args [ 0 ] [ 1 ] ) . group ( 'key' ) ) #NEWLINE# self . addCleanup ( patcher . stop )