#NEWLINE# def test_rsync_db_change_after_sync( self ) : #NEWLINE# #INDENT# class MyTestReplicator ( TestReplicator ) : #NEWLINE# #INDENT# def __init__( self , broker ) : #NEWLINE# #INDENT# super ( MyTestReplicator , self ) . __init__ ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . broker = broker #NEWLINE# self . _rsync_file_call_count = 0 #NEWLINE# #UNINDENT# def _rsync_file( self_ , db_file , remote_file , whole_file = True , different_region = False ) : #NEWLINE# #INDENT# self_ . _rsync_file_call_count += 1 #NEWLINE# if ( self_ . _rsync_file_call_count == 1 ) : #NEWLINE# #INDENT# self . assertEqual ( True , whole_file ) #NEWLINE# self . assertEqual ( False , self_ . broker . locked ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self_ . _rsync_file_call_count == 2 ) : #NEWLINE# #INDENT# self . assertEqual ( False , whole_file ) #NEWLINE# self . assertEqual ( True , self_ . broker . locked ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise RuntimeError ( '_rsync_file() called too many times' ) #NEWLINE# #UNINDENT# #UNINDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# with patch ( 'os.path.exists' , ( lambda * args : True ) ) : #NEWLINE# #INDENT# broker = FakeBroker ( ) #NEWLINE# replicator = MyTestReplicator ( broker ) #NEWLINE# fake_device = { #NEWLINE# #INDENT# 'ip' : '127.0.0.1' , #NEWLINE# 'replication_ip' : '127.0.0.1' , #NEWLINE# 'device' : 'sda1' , #NEWLINE# #UNINDENT# } #NEWLINE# replicator . _rsync_db ( broker , fake_device , ReplHttp ( ) , 'abcd' ) #NEWLINE# self . assertEqual ( 2 , broker . _rsync_file_call_count ) #NEWLINE# #UNINDENT# with patch ( 'os.path.exists' , ( lambda * args : False ) ) : #NEWLINE# #INDENT# with patch ( 'os.path.getmtime' , ChangingMtimesOs ( ) ) : #NEWLINE# #INDENT# broker = FakeBroker ( ) #NEWLINE# replicator = MyTestReplicator ( broker ) #NEWLINE# fake_device = { #NEWLINE# #INDENT# 'ip' : '127.0.0.1' , #NEWLINE# 'replication_ip' : '127.0.0.1' , #NEWLINE# 'device' : 'sda1' , #NEWLINE# #UNINDENT# } #NEWLINE# replicator . _rsync_db ( broker , fake_device , ReplHttp ( ) , 'abcd' ) #NEWLINE# self . assertEqual ( 2 , replicator . _rsync_file_call_count )