#NEWLINE# def test_delete_objs_ssync_only_when_in_sync( self ) : #NEWLINE# #INDENT# self . replicator . logger = debug_logger ( 'test-replicator' ) #NEWLINE# with mock . patch ( 'swift.obj.replicator.http_connect' , mock_http_connect ( 200 ) ) : #NEWLINE# #INDENT# df = self . df_mgr . get_diskfile ( 'sda' , '1' , 'a' , 'c' , 'o' , policy = POLICIES . legacy ) #NEWLINE# mkdirs ( df . _datadir ) #NEWLINE# ts = normalize_timestamp ( time . time ( ) ) #NEWLINE# f = open ( os . path . join ( df . _datadir , ( ts + '.data' ) ) , 'wb' ) #NEWLINE# f . write ( '0' ) #NEWLINE# f . close ( ) #NEWLINE# ohash = hash_path ( 'a' , 'c' , 'o' ) #NEWLINE# whole_path_from = storage_directory ( self . objects , 1 , ohash ) #NEWLINE# suffix_dir_path = os . path . dirname ( whole_path_from ) #NEWLINE# part_path = os . path . join ( self . objects , '1' ) #NEWLINE# self . assertTrue ( os . access ( part_path , os . F_OK ) ) #NEWLINE# self . call_nums = 0 #NEWLINE# self . conf [ 'sync_method' ] = 'ssync' #NEWLINE# in_sync_objs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# def _fake_ssync( node , job , suffixes , remote_check_objs = None ) : #NEWLINE# #INDENT# self . call_nums += 1 #NEWLINE# if ( remote_check_objs is None ) : #NEWLINE# #INDENT# ret_val = { #NEWLINE# #INDENT# ohash : ts , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ret_val = in_sync_objs #NEWLINE# #UNINDENT# return ( True , ret_val ) #NEWLINE# #UNINDENT# self . replicator . sync_method = _fake_ssync #NEWLINE# self . replicator . replicate ( ) #NEWLINE# self . assertEqual ( 3 , self . call_nums ) #NEWLINE# self . assertTrue ( os . access ( whole_path_from , os . F_OK ) ) #NEWLINE# self . assertTrue ( os . access ( suffix_dir_path , os . F_OK ) ) #NEWLINE# self . assertTrue ( os . access ( part_path , os . F_OK ) ) #NEWLINE# del self . call_nums