Beispiel #1
0
 def testApplicationErrorState(self):
   status = remote.RpcStatus(state=remote.RpcState.APPLICATION_ERROR,
                             error_message='an application error',
                             error_name='blam')
   try:
     remote.check_rpc_status(status)
     self.fail('Should have raised application error.')
   except remote.ApplicationError, err:
     self.assertEquals('an application error', str(err))
     self.assertEquals('blam', err.error_name)
Beispiel #2
0
 def testApplicationErrorState(self):
   status = remote.RpcStatus(state=remote.RpcState.APPLICATION_ERROR,
                             error_message='an application error',
                             error_name='blam')
   try:
     remote.check_rpc_status(status)
     self.fail('Should have raised application error.')
   except remote.ApplicationError as err:
     self.assertEquals('an application error', str(err))
     self.assertEquals('blam', err.error_name)
Beispiel #3
0
 def __http_error_to_exception(self, http_error):
   error_code = http_error.code
   content_type = http_error.hdrs.get('content-type')
   if content_type == self.protocol.CONTENT_TYPE:
     try:
       rpc_status = self.protocol.decode_message(remote.RpcStatus,
                                                 http_error.read())
     except Exception, decode_err:
       logging.warning(
         'An error occurred trying to parse status: %s\n%s',
         str(decode_err), http_error.msg)
     else:
       # TODO: Move the check_rpc_status to the Rpc.response property.
       # Will raise exception if rpc_status is in an error state.
       remote.check_rpc_status(rpc_status)
Beispiel #4
0
 def testNoError(self):
   for state in (remote.RpcState.OK, remote.RpcState.RUNNING):
     remote.check_rpc_status(remote.RpcStatus(state=state))
Beispiel #5
0
 def testNoError(self):
   for state in (remote.RpcState.OK, remote.RpcState.RUNNING):
     remote.check_rpc_status(remote.RpcStatus(state=state))