#NEWLINE# @ mock . patch ( 'oslo_vmware.rw_handles.ImageReadHandle' ) #NEWLINE# @ mock . patch . object ( image_transfer , 'download_stream_optimized_data' ) #NEWLINE# def test_download_stream_optimized_image( self , fake_download_stream_optimized_data , fake_rw_handles_ImageReadHandle ) : #NEWLINE# #INDENT# context = mock . Mock ( ) #NEWLINE# session = mock . Mock ( ) #NEWLINE# image_id = mock . Mock ( ) #NEWLINE# timeout_secs = 10 #NEWLINE# image_size = 1000 #NEWLINE# host = '127.0.0.1' #NEWLINE# port = 443 #NEWLINE# resource_pool = 'rp-1' #NEWLINE# vm_folder = 'folder-1' #NEWLINE# vm_import_spec = None #NEWLINE# fake_iter = 'fake_iter' #NEWLINE# image_service = mock . Mock ( ) #NEWLINE# image_service . download = mock . Mock ( ) #NEWLINE# image_service . download . return_value = fake_iter #NEWLINE# fake_ImageReadHandle = 'fake_ImageReadHandle' #NEWLINE# fake_rw_handles_ImageReadHandle . return_value = fake_ImageReadHandle #NEWLINE# image_transfer . download_stream_optimized_image ( context , timeout_secs , image_service , image_id , session = session , host = host , port = port , resource_pool = resource_pool , vm_folder = vm_folder , vm_import_spec = vm_import_spec , image_size = image_size ) #NEWLINE# image_service . download . assert_called_once_with ( context , image_id ) #NEWLINE# fake_rw_handles_ImageReadHandle . assert_called_once_with ( fake_iter ) #NEWLINE# fake_download_stream_optimized_data . assert_called_once_with ( context , timeout_secs , fake_ImageReadHandle , session = session , host = host , port = port , resource_pool = resource_pool , vm_folder = vm_folder , vm_import_spec = vm_import_spec , image_size = image_size )