Skip to content

Commit 15e3fa1

Browse files
committed
grpc unit test: throw exception from result mock
1 parent fbb76d1 commit 15e3fa1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/unit_grpc/test_futures.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def mock_grpc_future(
1515
grpc_future.exception.return_value = exception
1616
grpc_future.running.return_value = running
1717
grpc_future.result.return_value = result
18+
if exception:
19+
grpc_future.result.side_effect = exception
1820
return grpc_future
1921

2022

@@ -309,6 +311,7 @@ def test_result_catch_grpc_exceptions(self, mocker):
309311
def test_exception_when_done_maps_grpc_exception(self, mocker):
310312
grpc_future = mock_grpc_future(mocker, done=True)
311313
grpc_future.exception.return_value = FakeGrpcError(mocker)
314+
grpc_future.result.side_effect = grpc_future.exception.return_value
312315

313316
future = PineconeGrpcFuture(grpc_future)
314317

@@ -467,6 +470,7 @@ def test_concurrent_futures_wait_first_exception(self, mocker):
467470

468471
grpc_future2 = mock_grpc_future(mocker, done=True)
469472
grpc_future2.exception.return_value = Exception("Simulated gRPC error")
473+
grpc_future2.result.side_effect = grpc_future2.exception.return_value
470474
future2 = PineconeGrpcFuture(grpc_future2)
471475

472476
from concurrent.futures import wait, FIRST_EXCEPTION

0 commit comments

Comments
 (0)