Skip to content

Commit

Permalink
Merge pull request deepset-ai#38 from Anant/2.0-write_documents_test_…
Browse files Browse the repository at this point in the history
…default

add test for default write documents behavior
  • Loading branch information
mounaTay authored Dec 16, 2023
2 parents 4eeaff4 + 84c53ec commit 203e592
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ def test_comparison_equal_with_none(self, document_store, filterable_docs):
# Astra does not support filtering on None, it returns empty list
self.assert_documents_are_equal(result, [])

def test_write_documents(self, document_store: AstraDocumentStore):
"""
Test write_documents() overwrites stored Document when trying to write one with same id
using DuplicatePolicy.OVERWRITE.
"""
doc1 = Document(id="1", content="test doc 1")
doc2 = Document(id="1", content="test doc 2")

assert document_store.write_documents([doc2], policy=DuplicatePolicy.OVERWRITE) == 1
self.assert_documents_are_equal(document_store.filter_documents(), [doc2])
assert document_store.write_documents(documents=[doc1], policy=DuplicatePolicy.OVERWRITE) == 1
self.assert_documents_are_equal(document_store.filter_documents(), [doc1])

def test_delete_documents_non_existing_document(self, document_store: AstraDocumentStore):
"""
Test delete_documents() doesn't delete any Document when called with non existing id.
Expand Down

0 comments on commit 203e592

Please sign in to comment.