Skip to content

Commit

Permalink
add test for default write documents behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaKusevska authored and mounaTay committed Dec 16, 2023
1 parent 4eeaff4 commit 84c53ec
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 84c53ec

Please sign in to comment.