#NEWLINE# @ ddt . data ( [ 1 , 1 ] , [ 1 , 2 ] , [ 2 , 1 ] , [ 3 , 5 ] ) #NEWLINE# @ ddt . unpack #NEWLINE# def test_list_and_download_objects_in_containers( self , num_cons , num_objs ) : #NEWLINE# #INDENT# con_list = [ { #NEWLINE# #INDENT# 'name' : ( 'connn_%s' % i ) , #NEWLINE# #UNINDENT# } for i in range ( num_cons ) ] #NEWLINE# obj_list = [ { #NEWLINE# #INDENT# 'name' : ( 'ooobj_%s' % i ) , #NEWLINE# #UNINDENT# } for i in range ( num_objs ) ] #NEWLINE# scenario = objects . SwiftObjects ( ) #NEWLINE# scenario . _list_containers = mock . MagicMock ( return_value = ( 'header' , con_list ) ) #NEWLINE# scenario . _list_objects = mock . MagicMock ( return_value = ( 'header' , obj_list ) ) #NEWLINE# scenario . _download_object = mock . MagicMock ( ) #NEWLINE# scenario . list_and_download_objects_in_containers ( ) #NEWLINE# scenario . _list_containers . assert_called_once_with ( ) #NEWLINE# con_calls = [ mock . call ( container [ 'name' ] , atomic_action = False ) for container in con_list ] #NEWLINE# scenario . _list_objects . assert_has_calls ( con_calls ) #NEWLINE# obj_calls = [ ] #NEWLINE# for container in con_list : #NEWLINE# #INDENT# for obj in obj_list : #NEWLINE# #INDENT# obj_calls . append ( mock . call ( container [ 'name' ] , obj [ 'name' ] , atomic_action = False ) ) #NEWLINE# #UNINDENT# #UNINDENT# scenario . _download_object . assert_has_calls ( obj_list , any_order = True ) #NEWLINE# list_key_suffix = 'container' #NEWLINE# if ( num_cons > 1 ) : #NEWLINE# #INDENT# list_key_suffix = ( '%i_containers' % num_cons ) #NEWLINE# #UNINDENT# self . _test_atomic_action_timer ( scenario . atomic_actions ( ) , ( 'swift.list_objects_in_%s' % list_key_suffix ) ) #NEWLINE# download_key_suffix = 'object' #NEWLINE# if ( ( num_cons * num_objs ) > 1 ) : #NEWLINE# #INDENT# download_key_suffix = ( '%i_objects' % ( num_cons * num_objs ) ) #NEWLINE# #UNINDENT# self . _test_atomic_action_timer ( scenario . atomic_actions ( ) , ( 'swift.download_%s' % download_key_suffix ) )