#NEWLINE# def testCreateInstance_SuccessWithWarning( self ) : #NEWLINE# #INDENT# 'Unit test of CreateInstance() with warning.' #NEWLINE# mock_api = MagicMock ( name = 'Mock Google Client API' ) #NEWLINE# self . gce_api . GetApi = MagicMock ( return_value = mock_api ) #NEWLINE# mock_api . instances . return_value . insert . return_value . execute . return_value = { #NEWLINE# #INDENT# 'name' : 'instance-name' , #NEWLINE# 'warnings' : [ { #NEWLINE# #INDENT# 'code' : 'some warning code' , #NEWLINE# 'message' : 'some warning message' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertTrue ( self . gce_api . CreateInstance ( 'instance-name' , 'machine-type' , 'image-name' ) ) #NEWLINE# self . assertEqual ( 1 , self . gce_api . GetApi . call_count ) #NEWLINE# mock_api . instances . return_value . insert . assert_called_once_with ( project = 'project-name' , zone = 'zone-name' , body = mock . ANY ) #NEWLINE# mock_api . instances . return_value . insert . return_value . execute . assert_called_once_with ( )