diff --git a/tests/test_document_store.py b/tests/test_document_store.py index a8818a40a..fa7656b0f 100644 --- a/tests/test_document_store.py +++ b/tests/test_document_store.py @@ -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.