#NEWLINE# def test_update_sync_store( self ) : #NEWLINE# #INDENT# klass = 'swift.container.sync_store.ContainerSyncStore' #NEWLINE# daemon = replicator . ContainerReplicator ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# daemon . sync_store = sync_store . ContainerSyncStore ( daemon . root , daemon . logger , daemon . mount_check ) #NEWLINE# ts_iter = make_timestamp_iter ( ) #NEWLINE# broker = self . _get_broker ( 'a' , 'c' , node_index = 0 ) #NEWLINE# timestamp = next ( ts_iter ) #NEWLINE# broker . initialize ( mock_remove . internal , POLICIES . default . idx ) #NEWLINE# info = broker . get_replication_info ( ) #NEWLINE# with mock . patch ( ( klass + '.remove_synced_container' ) ) as mock_remove : #NEWLINE# #INDENT# with mock . patch ( ( klass + '.add_synced_container' ) ) as mock_add : #NEWLINE# #INDENT# daemon . _post_replicate_hook ( broker , info , [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( 0 , mock_remove . call_count ) #NEWLINE# self . assertEqual ( 0 , mock_add . call_count ) #NEWLINE# timestamp = next ( ts_iter ) #NEWLINE# broker . update_metadata ( { #NEWLINE# #INDENT# 'X-Container-Sync-To' : ( '' , timestamp . internal ) , #NEWLINE# 'X-Container-Sync-Key' : ( '' , timestamp . internal ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# with mock . patch ( ( klass + '.remove_synced_container' ) ) as mock_remove : #NEWLINE# #INDENT# with mock . patch ( ( klass + '.add_synced_container' ) ) as mock_add : #NEWLINE# #INDENT# daemon . _post_replicate_hook ( broker , info , [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( 0 , mock_add . call_count ) #NEWLINE# mock_remove . assert_called_once_with ( broker ) #NEWLINE# timestamp = next ( ts_iter ) #NEWLINE# broker . update_metadata ( { #NEWLINE# #INDENT# 'X-Container-Sync-To' : ( 'a' , timestamp . internal ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# with mock . patch ( ( klass + '.remove_synced_container' ) ) as mock_remove : #NEWLINE# #INDENT# with mock . patch ( ( klass + '.add_synced_container' ) ) as mock_add : #NEWLINE# #INDENT# daemon . _post_replicate_hook ( broker , info , [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( 0 , mock_add . call_count ) #NEWLINE# mock_remove . assert_called_once_with ( broker ) #NEWLINE# timestamp = next ( ts_iter ) #NEWLINE# broker . update_metadata ( { #NEWLINE# #INDENT# 'X-Container-Sync-To' : ( '' , timestamp . internal ) , #NEWLINE# 'X-Container-Sync-Key' : ( 'secret' , timestamp . internal ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# with mock . patch ( ( klass + '.remove_synced_container' ) ) as mock_remove : #NEWLINE# #INDENT# with mock . patch ( ( klass + '.add_synced_container' ) ) as mock_add : #NEWLINE# #INDENT# daemon . _post_replicate_hook ( broker , info , [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( 0 , mock_add . call_count ) #NEWLINE# mock_remove . assert_called_once_with ( broker ) #NEWLINE# timestamp = next ( ts_iter ) #NEWLINE# broker . update_metadata ( { #NEWLINE# #INDENT# 'X-Container-Sync-To' : ( 'a' , timestamp . internal ) , #NEWLINE# 'X-Container-Sync-Key' : ( 'secret' , timestamp . internal ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# with mock . patch ( ( klass + '.remove_synced_container' ) ) as mock_remove : #NEWLINE# #INDENT# with mock . patch ( ( klass + '.add_synced_container' ) ) as mock_add : #NEWLINE# #INDENT# daemon . _post_replicate_hook ( broker , info , [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# mock_add . assert_called_once_with ( broker ) #NEWLINE# self . assertEqual ( 0 , mock_remove . call_count ) #NEWLINE# timestamp = next ( ts_iter ) #NEWLINE# broker . delete_db ( timestamp . internal ) #NEWLINE# broker . update_metadata ( { #NEWLINE# #INDENT# 'X-Container-Sync-To' : ( 'a' , timestamp . internal ) , #NEWLINE# 'X-Container-Sync-Key' : ( 'secret' , timestamp . internal ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# with mock . patch ( ( klass + '.remove_synced_container' ) ) as mock_remove : #NEWLINE# #INDENT# with mock . patch ( ( klass + '.add_synced_container' ) ) as mock_add : #NEWLINE# #INDENT# daemon . _post_replicate_hook ( broker , info , [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( 0 , mock_add . call_count ) #NEWLINE# mock_remove . assert_called_once_with ( broker )