#NEWLINE# def test_migrate_backend( self ) : #NEWLINE# #INDENT# with maybe_not_found ( ) : #NEWLINE# #INDENT# s3_blobs = sum ( ( 1 for b in self . db . new_db . _s3_bucket ( ) . objects . all ( ) ) ) #NEWLINE# self . assertEqual ( s3_blobs , 0 ) #NEWLINE# #UNINDENT# with tempdir ( ) as tmp : #NEWLINE# #INDENT# filename = join ( tmp , 'file.txt' ) #NEWLINE# ( migrated , skipped ) = mod . MIGRATIONS [ self . slug ] . migrate ( filename ) #NEWLINE# self . assertGreaterEqual ( migrated , self . test_size ) #NEWLINE# mod . BlobMigrationState . objects . get ( slug = self . slug ) #NEWLINE# with open ( filename ) as fh : #NEWLINE# #INDENT# lines = list ( fh ) #NEWLINE# #UNINDENT# ids = { d . _id for d in self . migrate_docs } #NEWLINE# migrated = { d [ '_id' ] for d in ( json . loads ( x ) for x in lines ) } #NEWLINE# self . assertEqual ( len ( ids . intersection ( migrated ) ) , self . test_size ) #NEWLINE# #UNINDENT# for doc in self . migrate_docs : #NEWLINE# #INDENT# exp = SavedBasicExport . get ( doc . _id ) #NEWLINE# self . assertEqual ( exp . _rev , doc . _rev ) #NEWLINE# self . assertTrue ( doc . blobs ) #NEWLINE# bucket = doc . _blobdb_bucket ( ) #NEWLINE# for meta in doc . blobs . values ( ) : #NEWLINE# #INDENT# content = self . db . new_db . get ( meta . id , bucket ) #NEWLINE# self . assertEqual ( len ( content . read ( ) ) , meta . content_length )