def _make_grpc_error(self, status_code): from grpc._channel import _RPCState from google.cloud.exceptions import GrpcRendezvous details = 'Some error details.' exc_state = _RPCState((), None, None, status_code, details) return GrpcRendezvous(exc_state, None, None, None)
def test_commit_failure_cancelled(self): from grpc import StatusCode from grpc._channel import _RPCState from google.cloud.exceptions import GrpcRendezvous exc_state = _RPCState((), None, None, StatusCode.CANCELLED, None) exc = GrpcRendezvous(exc_state, None, None, None) self._commit_failure_helper(exc, GrpcRendezvous)
def test_failure_cancelled(self): from grpc import StatusCode from grpc._channel import _RPCState from google.cloud.exceptions import GrpcRendezvous exc_state = _RPCState((), None, None, StatusCode.CANCELLED, None) exc = GrpcRendezvous(exc_state, None, None, None) with self.assertRaises(GrpcRendezvous): with self._call_fut(): self._fake_method(exc)
def test_commit_failure_aborted(self): from grpc import StatusCode from grpc._channel import _RPCState from google.cloud.exceptions import Conflict from google.cloud.exceptions import GrpcRendezvous details = 'Bad things.' exc_state = _RPCState((), None, None, StatusCode.ABORTED, details) exc = GrpcRendezvous(exc_state, None, None, None) self._commit_failure_helper(exc, Conflict)
def test_commit_failure_invalid_argument(self): from grpc import StatusCode from grpc._channel import _RPCState from google.cloud.exceptions import BadRequest from google.cloud.exceptions import GrpcRendezvous details = 'Too long content.' exc_state = _RPCState((), None, None, StatusCode.INVALID_ARGUMENT, details) exc = GrpcRendezvous(exc_state, None, None, None) self._commit_failure_helper(exc, BadRequest)
def test_run_query_invalid_argument(self): from grpc import StatusCode from grpc._channel import _RPCState from google.cloud.exceptions import BadRequest from google.cloud.exceptions import GrpcRendezvous details = ('Cannot have inequality filters on multiple ' 'properties: [created, priority]') exc_state = _RPCState((), None, None, StatusCode.INVALID_ARGUMENT, details) exc = GrpcRendezvous(exc_state, None, None, None) self._run_query_failure_helper(exc, BadRequest)
def test_failure_aborted(self): from grpc import StatusCode from grpc._channel import _RPCState from google.cloud.exceptions import Conflict from google.cloud.exceptions import GrpcRendezvous details = 'Bad things.' exc_state = _RPCState((), None, None, StatusCode.ABORTED, details) exc = GrpcRendezvous(exc_state, None, None, None) with self.assertRaises(Conflict): with self._call_fut(): self._fake_method(exc)
def test_failure_invalid_argument(self): from grpc import StatusCode from grpc._channel import _RPCState from google.cloud.exceptions import BadRequest from google.cloud.exceptions import GrpcRendezvous details = ('Cannot have inequality filters on multiple ' 'properties: [created, priority]') exc_state = _RPCState((), None, None, StatusCode.INVALID_ARGUMENT, details) exc = GrpcRendezvous(exc_state, None, None, None) with self.assertRaises(BadRequest): with self._call_fut(): self._fake_method(exc)
def _make_rendezvous(status_code, details): from grpc._channel import _RPCState from google.cloud.exceptions import GrpcRendezvous exc_state = _RPCState((), None, None, status_code, details) return GrpcRendezvous(exc_state, None, None, None)