#NEWLINE# def test_delete_db( self ) : #NEWLINE# #INDENT# db_replicator . lock_parent_directory = lock_parent_directory #NEWLINE# replicator = TestReplicator ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , logger = unit . FakeLogger ( ) ) #NEWLINE# replicator . _zero_stats ( ) #NEWLINE# replicator . extract_device = ( lambda _ : 'some_device' ) #NEWLINE# temp_dir = mkdtemp ( ) #NEWLINE# try : #NEWLINE# #INDENT# temp_suf_dir = os . path . join ( temp_dir , '16e' ) #NEWLINE# os . mkdir ( temp_suf_dir ) #NEWLINE# temp_hash_dir = os . path . join ( temp_suf_dir , '166e33924a08ede4204871468c11e16e' ) #NEWLINE# os . mkdir ( temp_hash_dir ) #NEWLINE# temp_file = NamedTemporaryFile ( dir = temp_hash_dir , delete = False ) #NEWLINE# temp_hash_dir2 = os . path . join ( temp_suf_dir , '266e33924a08ede4204871468c11e16e' ) #NEWLINE# os . mkdir ( temp_hash_dir2 ) #NEWLINE# temp_file2 = NamedTemporaryFile ( dir = temp_hash_dir2 , delete = False ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_dir ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_suf_dir ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_hash_dir ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_file . name ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_hash_dir2 ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_file2 . name ) ) #NEWLINE# self . assertEqual ( 0 , replicator . stats [ 'remove' ] ) #NEWLINE# temp_file . db_file = temp_file . name #NEWLINE# replicator . delete_db ( temp_file ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_dir ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_suf_dir ) ) #NEWLINE# self . assertFalse ( os . path . exists ( temp_hash_dir ) ) #NEWLINE# self . assertFalse ( os . path . exists ( temp_file . name ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_hash_dir2 ) ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_file2 . name ) ) #NEWLINE# self . assertEqual ( [ ( ( 'removes.some_device' , ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ] , replicator . logger . log_dict [ 'increment' ] ) #NEWLINE# self . assertEqual ( 1 , replicator . stats [ 'remove' ] ) #NEWLINE# temp_file2 . db_file = temp_file2 . name #NEWLINE# replicator . delete_db ( temp_file2 ) #NEWLINE# self . assertTrue ( os . path . exists ( temp_dir ) ) #NEWLINE# self . assertFalse ( os . path . exists ( temp_suf_dir ) ) #NEWLINE# self . assertFalse ( os . path . exists ( temp_hash_dir ) ) #NEWLINE# self . assertFalse ( os . path . exists ( temp_file . name ) ) #NEWLINE# self . assertFalse ( os . path . exists ( temp_hash_dir2 ) ) #NEWLINE# self . assertFalse ( os . path . exists ( temp_file2 . name ) ) #NEWLINE# self . assertEqual ( ( [ ( ( 'removes.some_device' , ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ] * 2 ) , replicator . logger . log_dict [ 'increment' ] ) #NEWLINE# self . assertEqual ( 2 , replicator . stats [ 'remove' ] ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# rmtree ( temp_dir )