Skip to content

Commit 273a57b

Browse files
committed
Trial mock gcs url test
1 parent f45e4de commit 273a57b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/unit_tests/v2/test_async_pg_vectorstore.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from unittest.mock import MagicMock, patch
23
import uuid
34
from typing import AsyncIterator, Sequence
45

@@ -216,9 +217,21 @@ async def test_adelete(self, engine: PGEngine, vs: AsyncPGVectorStore) -> None:
216217
assert result == False
217218
await aexecute(engine, f'TRUNCATE TABLE "{DEFAULT_TABLE}"')
218219

220+
@patch('langchain_postgres.v2.async_vectorstore.storage.Client')
219221
async def test_aadd_images(
220-
self, engine: PGEngine, image_vs: AsyncPGVectorStore, image_uris: list[str]
222+
self, MockStorageClient: MagicMock, engine: PGEngine, image_vs: AsyncPGVectorStore, image_uris: list[str]
221223
) -> None:
224+
mock_blob_instance = MagicMock()
225+
fake_image_bytes = b"fake_gcs_image_data" # Differentiated fake data
226+
mock_blob_instance.download_as_bytes.return_value = fake_image_bytes
227+
228+
mock_bucket_instance = MagicMock()
229+
mock_bucket_instance.blob.return_value = mock_blob_instance
230+
231+
mock_storage_client_instance = MagicMock()
232+
mock_storage_client_instance.bucket.return_value = mock_bucket_instance
233+
234+
MockStorageClient.return_value = mock_storage_client_instance
222235
ids = [str(uuid.uuid4()) for i in range(len(image_uris))]
223236
metadatas = [
224237
{"image_id": str(i), "source": "postgres"} for i in range(len(image_uris))

0 commit comments

Comments
 (0)