Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 98eae06

Browse files
committed
add test_open_error_call_error unit test
1 parent d01421b commit 98eae06

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/asyncio/test_bidi_async.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
pytest.skip("No GRPC", allow_module_level=True)
3232

3333
from google.api_core import bidi_async
34+
from google.api_core import exceptions
3435

3536

3637
if sys.version_info < (3, 10): # type: ignore[operator]
@@ -222,6 +223,23 @@ async def test_open_error_already_open(self):
222223
with pytest.raises(ValueError):
223224
await bidi_rpc.open()
224225

226+
@pytest.mark.asyncio
227+
async def test_open_error_call_error(self):
228+
rpc, _ = make_async_rpc()
229+
expected_exception = exceptions.GoogleAPICallError(
230+
"test", response=mock.sentinel.response
231+
)
232+
rpc.side_effect = expected_exception
233+
bidi_rpc = bidi_async.AsyncBidiRpc(rpc)
234+
callback = mock.Mock(spec=["__call__"])
235+
bidi_rpc.add_done_callback(callback)
236+
237+
with pytest.raises(exceptions.GoogleAPICallError) as exc_info:
238+
await bidi_rpc.open()
239+
240+
assert exc_info.value == expected_exception
241+
callback.assert_called_once_with(mock.sentinel.response)
242+
225243
@pytest.mark.asyncio
226244
async def test_close(self):
227245
rpc, call = make_async_rpc()

0 commit comments

Comments
 (0)