#NEWLINE# def _test_get_info( self , vm_exists ) : #NEWLINE# #INDENT# mock_instance = fake_instance . fake_instance_obj ( self . context ) #NEWLINE# mock_info = mock . MagicMock ( spec_set = dict ) #NEWLINE# fake_info = { #NEWLINE# #INDENT# 'EnabledState' : 2 , #NEWLINE# 'MemoryUsage' : mock . sentinel . FAKE_MEM_KB , #NEWLINE# 'NumberOfProcessors' : mock . sentinel . FAKE_NUM_CPU , #NEWLINE# 'UpTime' : mock . sentinel . FAKE_CPU_NS , #NEWLINE# #UNINDENT# } #NEWLINE# def getitem( key ) : #NEWLINE# #INDENT# return fake_info [ key ] #NEWLINE# #UNINDENT# mock_info . __getitem__ . side_effect = getitem #NEWLINE# expected = hardware . InstanceInfo ( state = constants . HYPERV_POWER_STATE [ 2 ] , max_mem_kb = mock . sentinel . FAKE_MEM_KB , mem_kb = mock . sentinel . FAKE_MEM_KB , num_cpu = mock . sentinel . FAKE_NUM_CPU , cpu_time_ns = mock . sentinel . FAKE_CPU_NS ) #NEWLINE# self . _vmops . _vmutils . vm_exists . return_value = vm_exists #NEWLINE# self . _vmops . _vmutils . get_vm_summary_info . return_value = mock_info #NEWLINE# if ( not vm_exists ) : #NEWLINE# #INDENT# self . assertRaises ( exception . InstanceNotFound , self . _vmops . get_info , mock_instance ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# response = self . _vmops . get_info ( mock_instance ) #NEWLINE# self . _vmops . _vmutils . vm_exists . assert_called_once_with ( mock_instance . name ) #NEWLINE# self . _vmops . _vmutils . get_vm_summary_info . assert_called_once_with ( mock_instance . name ) #NEWLINE# self . assertEqual ( response , expected )