#NEWLINE# def _call_live_migrate_command_with_migrate_send_data( self , migrate_data ) : #NEWLINE# #INDENT# command_name = 'test_command' #NEWLINE# vm_ref = 'vm_ref' #NEWLINE# def side_effect( method , * args ) : #NEWLINE# #INDENT# if ( method == 'SR.get_by_uuid' ) : #NEWLINE# #INDENT# return 'sr_ref_new' #NEWLINE# #UNINDENT# xmlrpclib . dumps ( args , method , allow_none = 1 ) #NEWLINE# #UNINDENT# with mock . patch . object ( self . vmops , '_generate_vdi_map' ) as mock_gen_vdi_map , mock . patch . object ( self . vmops . _session , 'call_xenapi' ) as mock_call_xenapi : #NEWLINE# #INDENT# mock_call_xenapi . side_effect = side_effect #NEWLINE# mock_gen_vdi_map . side_effect = [ { #NEWLINE# #INDENT# 'vdi' : 'sr_ref' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'vdi' : 'sr_ref_2' , #NEWLINE# #UNINDENT# } ] #NEWLINE# self . vmops . _call_live_migrate_command ( command_name , vm_ref , migrate_data ) #NEWLINE# expected_vdi_map = { #NEWLINE# #INDENT# 'vdi' : 'sr_ref' , #NEWLINE# #UNINDENT# } #NEWLINE# if ( 'sr_uuid_map' in migrate_data ) : #NEWLINE# #INDENT# expected_vdi_map = { #NEWLINE# #INDENT# 'vdi' : 'sr_ref_2' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# self . assertEqual ( mock_call_xenapi . call_args_list [ ( - 1 ) ] , mock . call ( 'test_command' , vm_ref , migrate_data . migrate_send_data , True , expected_vdi_map , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . assertEqual ( mock_gen_vdi_map . call_args_list [ 0 ] , mock . call ( migrate_data . destination_sr_ref , vm_ref ) ) #NEWLINE# if ( 'sr_uuid_map' in migrate_data ) : #NEWLINE# #INDENT# self . assertEqual ( mock_gen_vdi_map . call_args_list [ 1 ] , mock . call ( migrate_data . sr_uuid_map [ 'sr_uuid2' ] , vm_ref , 'sr_ref_new' ) )