#NEWLINE# def _test_invalid_state( self , action , method = None , body_map = None , compute_api_args_map = None , exception_arg = None ) : #NEWLINE# #INDENT# if ( method is None ) : #NEWLINE# #INDENT# method = action . replace ( '_' , '' ) #NEWLINE# #UNINDENT# if ( body_map is None ) : #NEWLINE# #INDENT# body_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( compute_api_args_map is None ) : #NEWLINE# #INDENT# compute_api_args_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# instance = self . _stub_instance_get ( ) #NEWLINE# ( args , kwargs ) = compute_api_args_map . get ( method , ( ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# getattr ( self . compute_api , method ) ( self . context , instance , * args , ** kwargs ) . AndRaise ( exception . InstanceInvalidState ( attr = 'vm_state' , instance_uuid = instance . uuid , state = 'foo' , method = method ) ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# controller_function = getattr ( self . controller , action ) #NEWLINE# ex = self . assertRaises ( webob . exc . HTTPConflict , controller_function , self . req , instance . uuid , body = body_map ) #NEWLINE# self . assertIn ( ( "Cannot '%(action)s' instance %(id)s" % { #NEWLINE# #INDENT# 'action' : ( exception_arg or method ) , #NEWLINE# 'id' : instance . uuid , #NEWLINE# #UNINDENT# } ) , ex . explanation ) #NEWLINE# self . mox . VerifyAll ( ) #NEWLINE# self . mox . UnsetStubs ( )