Skip to content

Commit ab5c41d

Browse files
committed
Fix tests
1 parent da0f012 commit ab5c41d

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

tests/test_async_vectorstore_search.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,34 @@ async def engine(self, db_project, db_region, db_cluster, db_instance, db_name):
114114
await engine.close()
115115

116116
@pytest_asyncio.fixture(scope="class")
117-
async def vs_custom_scann_query_option(self, engine):
117+
async def vs_custom(self, engine):
118+
await engine._ainit_vectorstore_table(
119+
CUSTOM_TABLE,
120+
VECTOR_SIZE,
121+
id_column="myid",
122+
content_column="mycontent",
123+
embedding_column="myembedding",
124+
metadata_columns=[
125+
Column("page", "TEXT"),
126+
Column("source", "TEXT"),
127+
],
128+
store_metadata=False,
129+
)
130+
131+
vs_custom = await AsyncAlloyDBVectorStore.create(
132+
engine,
133+
embedding_service=embeddings_service,
134+
table_name=CUSTOM_TABLE,
135+
id_column="myid",
136+
content_column="mycontent",
137+
embedding_column="myembedding",
138+
index_query_options=HNSWQueryOptions(ef_search=1),
139+
)
140+
await vs_custom.aadd_documents(docs, ids=ids)
141+
yield vs_custom
142+
143+
@pytest_asyncio.fixture(scope="class")
144+
async def vs_custom_scann_query_option(self, engine, vs_custom):
118145
vs_custom_scann_query_option = await AsyncAlloyDBVectorStore.create(
119146
engine,
120147
embedding_service=embeddings_service,

tests/test_vectorstore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async def test_aadd_images(self, engine_sync, image_uris):
194194
await aexecute(engine_sync, f'DROP TABLE IF EXISTS "{IMAGE_TABLE}"')
195195

196196
async def test_aadd_images_store_uri_only(self, engine_sync, image_uris):
197-
table_name = IMAGE_TABLE_SYNC + "_store_uri_only"
197+
table_name = IMAGE_TABLE_SYNC + "_uri"
198198
engine_sync.init_vectorstore_table(
199199
table_name,
200200
VECTOR_SIZE,
@@ -254,7 +254,7 @@ async def test_add_images(self, engine_sync, image_uris):
254254
await aexecute(engine_sync, f'DROP TABLE IF EXISTS "{IMAGE_TABLE_SYNC}"')
255255

256256
async def test_add_images_store_uri_only(self, engine_sync, image_uris):
257-
table_name = IMAGE_TABLE_SYNC + "_store_uri_only"
257+
table_name = IMAGE_TABLE_SYNC + "_uri"
258258
engine_sync.init_vectorstore_table(
259259
table_name,
260260
VECTOR_SIZE,

tests/test_vectorstore_embeddings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def test_asimilarity_search(self, vs):
183183
results = await vs.asimilarity_search("foo", k=1)
184184
assert len(results) == 1
185185
assert results == [Document(page_content="foo", id=ids[0])]
186-
results = await vs.asimilarity_search("foo", k=1, filter={"mycontent": "bar"})
186+
results = await vs.asimilarity_search("foo", k=1, filter={"content": "bar"})
187187
assert results == [Document(page_content="bar", id=ids[1])]
188188

189189
async def test_asimilarity_search_score(self, vs):
@@ -242,7 +242,7 @@ async def test_amax_marginal_relevance_search(self, vs):
242242
results = await vs.amax_marginal_relevance_search("bar")
243243
assert results[0] == Document(page_content="bar", id=ids[1])
244244
results = await vs.amax_marginal_relevance_search(
245-
"bar", filter={"mycontent": "boo"}
245+
"bar", filter={"content": "boo"}
246246
)
247247
assert results[0] == Document(page_content="boo", id=ids[3])
248248

@@ -343,7 +343,7 @@ def test_similarity_search(self, vs_custom):
343343
assert len(results) == 1
344344
assert results == [Document(page_content="foo", id=ids[0])]
345345
results = vs_custom.similarity_search("foo", k=1, filter={"mycontent": "boo"})
346-
assert results == [Document(page_content="bar", id=ids[1])]
346+
assert results == [Document(page_content="boo", id=ids[3])]
347347

348348
def test_similarity_search_score(self, vs_custom):
349349
results = vs_custom.similarity_search_with_score("foo")

0 commit comments

Comments
 (0)