Skip to content

Commit

Permalink
Fix Astra integration tests (#13520)
Browse files Browse the repository at this point in the history
- **Description:** Fix Astra integration tests that are failing. The
`delete` always return True as the deletion is successful if no errors
are thrown. I aligned the test to verify this behaviour
  - **Tag maintainer:** @hemidactylus 
  - **Twitter handle:** nicoloboschi

---------

Co-authored-by: Bagatur <[email protected]>
  • Loading branch information
nicoloboschi and baskaryan authored Nov 20, 2023
1 parent 69d39e2 commit ad0c3b9
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ def test_astradb_vectorstore_crud(self, store_someemb: AstraDB) -> None:
res2 = store_someemb.similarity_search("Abc", k=10)
assert len(res2) == 4
# pick one that was just updated and check its metadata
res3 = store_someemb.similarity_search_with_score_id("cc", k=1)
res3 = store_someemb.similarity_search_with_score_id(
query="cc", k=1, filter={"k": "c_new"}
)
print(str(res3))
doc3, score3, id3 = res3[0]
assert doc3.page_content == "cc"
assert doc3.metadata == {"k": "c_new", "ord": 102}
Expand All @@ -217,7 +220,7 @@ def test_astradb_vectorstore_crud(self, store_someemb: AstraDB) -> None:
del1_res = store_someemb.delete(["b"])
assert del1_res is True
del2_res = store_someemb.delete(["a", "c", "Z!"])
assert del2_res is False # a non-existing ID was supplied
assert del2_res is True # a non-existing ID was supplied
assert len(store_someemb.similarity_search("xy", k=10)) == 1
# clear store
store_someemb.clear()
Expand All @@ -231,7 +234,7 @@ def test_astradb_vectorstore_crud(self, store_someemb: AstraDB) -> None:
ids=["v", "w"],
)
assert len(store_someemb.similarity_search("xy", k=10)) == 2
res4 = store_someemb.similarity_search("ww", k=1)
res4 = store_someemb.similarity_search("ww", k=1, filter={"k": "w"})
assert res4[0].metadata["ord"] == 205

def test_astradb_vectorstore_mmr(self, store_parseremb: AstraDB) -> None:
Expand Down Expand Up @@ -346,7 +349,7 @@ def test_astradb_vectorstore_massive_delete(self, store_someemb: AstraDB) -> Non
assert del_res0 is True
# deleting the rest plus a fake one
del_res1 = store_someemb.delete(ids1 + ["ghost!"])
assert del_res1 is False # not *all* ids could be deleted...
assert del_res1 is True # ensure no error
# nothing left
assert store_someemb.similarity_search("x", k=2 * M) == []

Expand Down

0 comments on commit ad0c3b9

Please sign in to comment.