#NEWLINE# @ mock . patch . object ( Site . objects , 'get_current' ) #NEWLINE# def test_watch_forum_then_new_thread( self , get_current ) : #NEWLINE# #INDENT# 'Watching a forum and creating a new thread should send email.' #NEWLINE# get_current . return_value . domain = 'testserver' #NEWLINE# u = UserFactory ( ) #NEWLINE# d = DocumentFactory ( title = 'an article title' ) #NEWLINE# f = self . _toggle_watch_kbforum_as ( u . username , d , turn_on = True ) #NEWLINE# u2 = UserFactory ( username = 'jsocol' ) #NEWLINE# self . client . login ( username = u2 . username , password = 'testpass' ) #NEWLINE# post ( self . client , 'wiki.discuss.new_thread' , { #NEWLINE# #INDENT# 'title' : 'a title' , #NEWLINE# 'content' : 'a post' , #NEWLINE# #UNINDENT# } , args = [ f . slug ] ) #NEWLINE# t = Thread . objects . all ( ) . order_by ( '-id' ) [ 0 ] #NEWLINE# attrs_eq ( mail . outbox [ 0 ] , to = [ u2 . email ] , subject = 'an article title - a title' ) #NEWLINE# starts_with ( mail . outbox [ 0 ] . body , ( NEW_THREAD_EMAIL % { #NEWLINE# #INDENT# 'user' : u2 . profile . name , #NEWLINE# 'document_slug' : d . slug , #NEWLINE# 'thread_id' : t . id , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . _toggle_watch_kbforum_as ( u . username , d , turn_on = False )