#NEWLINE# @ mock . patch ( 'website.mails.send_mail' ) #NEWLINE# @ mock . patch ( 'website.archiver.tasks.archive_success.delay' ) #NEWLINE# def test_archive_callback_on_tree_sends_only_one_email( self , mock_send_success , mock_arhive_success ) : #NEWLINE# #INDENT# proj = factories . NodeFactory ( ) #NEWLINE# child = factories . NodeFactory ( parent = proj ) #NEWLINE# factories . NodeFactory ( parent = child ) #NEWLINE# reg = factories . RegistrationFactory ( project = proj ) #NEWLINE# rchild = reg . nodes [ 0 ] #NEWLINE# rchild2 = rchild . nodes [ 0 ] #NEWLINE# for node in [ reg , rchild , rchild2 ] : #NEWLINE# #INDENT# for addon in [ 'dropbox' , 'osfstorage' ] : #NEWLINE# #INDENT# node . archive_job . _set_target ( addon ) #NEWLINE# #UNINDENT# #UNINDENT# for node in [ reg , rchild , rchild2 ] : #NEWLINE# #INDENT# for addon in [ 'dropbox' , 'osfstorage' ] : #NEWLINE# #INDENT# node . archive_job . update_target ( addon , ARCHIVER_INITIATED ) #NEWLINE# #UNINDENT# #UNINDENT# for addon in [ 'dropbox' , 'osfstorage' ] : #NEWLINE# #INDENT# rchild . archive_job . update_target ( addon , ARCHIVER_SUCCESS ) #NEWLINE# #UNINDENT# rchild . save ( ) #NEWLINE# listeners . archive_callback ( rchild ) #NEWLINE# assert_false ( mock_send_success . called ) #NEWLINE# for addon in [ 'dropbox' , 'osfstorage' ] : #NEWLINE# #INDENT# reg . archive_job . update_target ( addon , ARCHIVER_SUCCESS ) #NEWLINE# #UNINDENT# reg . save ( ) #NEWLINE# listeners . archive_callback ( reg ) #NEWLINE# assert_false ( mock_send_success . called ) #NEWLINE# for addon in [ 'dropbox' , 'osfstorage' ] : #NEWLINE# #INDENT# rchild2 . archive_job . update_target ( addon , ARCHIVER_SUCCESS ) #NEWLINE# #UNINDENT# rchild2 . save ( ) #NEWLINE# listeners . archive_callback ( rchild2 ) #NEWLINE# assert_equal ( mock_send_success . call_count , 1 ) #NEWLINE# assert_true ( mock_send_success . called )