Skip to content

Commit

Permalink
Merge branch 'main' into rest-streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Jun 4, 2024
2 parents 043b2ac + c9e1cbb commit ff9cfb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
7 changes: 3 additions & 4 deletions google/api_core/grpc_helpers_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,15 @@ def wrap_errors(callable_):
Returns: Callable: The wrapped gRPC callable.
"""
grpc_helpers._patch_callable_name(callable_)
if isinstance(callable_, aio.UnaryUnaryMultiCallable):
return _wrap_unary_errors(callable_)
elif isinstance(callable_, aio.UnaryStreamMultiCallable):

if isinstance(callable_, aio.UnaryStreamMultiCallable):
return _wrap_stream_errors(callable_, _WrappedUnaryStreamCall)
elif isinstance(callable_, aio.StreamUnaryMultiCallable):
return _wrap_stream_errors(callable_, _WrappedStreamUnaryCall)
elif isinstance(callable_, aio.StreamStreamMultiCallable):
return _wrap_stream_errors(callable_, _WrappedStreamStreamCall)
else:
raise TypeError("Unexpected type of callable: {}".format(type(callable_)))
return _wrap_unary_errors(callable_)


def create_channel(
Expand Down
13 changes: 0 additions & 13 deletions tests/asyncio/test_grpc_helpers_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,6 @@ async def test_wrap_stream_errors_stream_stream():
assert mock_call.wait_for_connection.call_count == 1


@pytest.mark.asyncio
async def test_wrap_errors_type_error():
"""
If wrap_errors is called with an unexpected type, it should raise a TypeError.
"""
mock_call = mock.Mock()
multicallable = mock.Mock(return_value=mock_call)

with pytest.raises(TypeError) as exc:
grpc_helpers_async.wrap_errors(multicallable)
assert "Unexpected type" in str(exc.value)


@pytest.mark.asyncio
async def test_wrap_stream_errors_raised():
grpc_error = RpcErrorImpl(grpc.StatusCode.INVALID_ARGUMENT)
Expand Down

0 comments on commit ff9cfb3

Please sign in to comment.