#NEWLINE# def test_find_failed_registrations( self ) : #NEWLINE# #INDENT# failures = [ ] #NEWLINE# legacy = [ ] #NEWLINE# delta = datetime . timedelta ( days = 2 ) #NEWLINE# for i in range ( 5 ) : #NEWLINE# #INDENT# reg = factories . RegistrationFactory ( ) #NEWLINE# reg . archive_job . _fields [ 'datetime_initiated' ] . __set__ ( reg . archive_job , ( datetime . datetime . now ( ) - delta ) , safe = True ) #NEWLINE# reg . save ( ) #NEWLINE# ArchiveJob . remove_one ( reg . archive_job ) #NEWLINE# legacy . append ( reg . _id ) #NEWLINE# #UNINDENT# for i in range ( 5 ) : #NEWLINE# #INDENT# reg = factories . RegistrationFactory ( ) #NEWLINE# reg . archive_job . _fields [ 'datetime_initiated' ] . __set__ ( reg . archive_job , ( datetime . datetime . now ( ) - delta ) , safe = True ) #NEWLINE# reg . archive_job . status = ARCHIVER_INITIATED #NEWLINE# reg . archive_job . save ( ) #NEWLINE# reg . save ( ) #NEWLINE# for addon in [ 'osfstorage' , 'dropbox' ] : #NEWLINE# #INDENT# reg . archive_job . _set_target ( addon ) #NEWLINE# reg . archive_job . update_target ( addon , ARCHIVER_INITIATED ) #NEWLINE# #UNINDENT# reg . archive_job . sent = False #NEWLINE# reg . archive_job . save ( ) #NEWLINE# failures . append ( reg . _id ) #NEWLINE# #UNINDENT# pending = [ ] #NEWLINE# for i in range ( 5 ) : #NEWLINE# #INDENT# reg = factories . RegistrationFactory ( ) #NEWLINE# for addon in [ 'osfstorage' , 'dropbox' ] : #NEWLINE# #INDENT# reg . archive_job . _set_target ( addon ) #NEWLINE# reg . archive_job . update_target ( addon , ARCHIVER_INITIATED ) #NEWLINE# #UNINDENT# reg . archive_job . save ( ) #NEWLINE# pending . append ( reg ) #NEWLINE# #UNINDENT# failed = scripts . find_failed_registrations ( ) #NEWLINE# assert_items_equal ( [ f . _id for f in failed ] , failures ) #NEWLINE# for pk in legacy : #NEWLINE# #INDENT# assert_false ( ( pk in failed ) )