#NEWLINE# @ mock . patch ( 'rally.deployment.serverprovider.providers.virsh.netaddr.IPAddress' ) #NEWLINE# @ mock . patch ( 'rally.deployment.serverprovider.providers.virsh.subprocess' ) #NEWLINE# @ mock . patch ( 'time.sleep' ) #NEWLINE# def test_create_vm( self , mock_sleep , mock_subprocess , mock_ip_address ) : #NEWLINE# #INDENT# mock_subprocess . check_output . return_value = '10.0.0.1' #NEWLINE# mock_ip_address . return_value = '10.0.0.2' #NEWLINE# server = self . provider . create_vm ( 'name' ) #NEWLINE# script_path = ( '%s/virsh/get_domain_ip.sh' % os . path . split ( virsh . __file__ ) [ 0 ] ) #NEWLINE# mock_subprocess . assert_has_calls ( [ mock . call . check_call ( [ 'virt-clone' , '--connect=qemu+ssh://user@host/system' , '-o' , 'prefix' , '-n' , 'name' , '--auto-clone' ] ) , mock . call . check_call ( [ 'virsh' , '--connect=qemu+ssh://user@host/system' , 'start' , 'name' ] ) , mock . call . check_call ( [ 'scp' , '-o StrictHostKeyChecking=no' , script_path , 'user@host:~/get_domain_ip.sh' ] ) , mock . call . check_output ( [ 'ssh' , '-o StrictHostKeyChecking=no' , 'user@host' , './get_domain_ip.sh' , 'name' ] ) ] ) #NEWLINE# mock_ip_address . assert_called_once_with ( '10.0.0.1' ) #NEWLINE# self . assertEqual ( server . host , '10.0.0.2' ) #NEWLINE# self . assertEqual ( server . user , 'user' ) #NEWLINE# self . assertIsNone ( script_path . key ) #NEWLINE# self . assertEqual ( server . password , 'password' ) #NEWLINE# self . provider . resources . create . assert_called_once_with ( { #NEWLINE# #INDENT# 'name' : 'name' , #NEWLINE# #UNINDENT# } )