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)
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)
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)
def testNoError(self): for state in (remote.RpcState.OK, remote.RpcState.RUNNING): remote.check_rpc_status(remote.RpcStatus(state=state))