Skip to content

Commit

Permalink
Fix broken unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Oct 31, 2024
1 parent 54c2fa3 commit b26f05e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/unit_grpc/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,18 @@ def test_exception_when_pending_timeout(self, mocker):
with pytest.raises(TimeoutError):
future.exception(timeout=1)

def test_add_done_callback(self, mocker):
grpc_future = mock_grpc_future(mocker, running=True)
future = PineconeGrpcFuture(grpc_future)

callback = mocker.MagicMock()
future.add_done_callback(callback)

grpc_future.done.return_value = True
future._sync_state(grpc_future)

callback.assert_called_once_with(future)

def test_concurrent_futures_as_completed(self, mocker):
grpc_future = mock_grpc_future(mocker, running=True)

Expand Down
20 changes: 19 additions & 1 deletion tests/unit_grpc/test_grpc_index_upsert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,27 @@ class MockUpsertDelegate:
def __init__(self, upsert_response: UpsertResponse):
self.response = upsert_response

def result(self, timeout):
def result(self, timeout=None):
return self.response

def cancelled(self):
return False

def cancel(self):
pass

def exception(self, timeout=None):
return None

def done(self):
return True

def running(self):
return False

def add_done_callback(self, callback):
pass


@pytest.fixture
def expected_vec1(vals1):
Expand Down

0 comments on commit b26f05e

Please sign in to comment.