Skip to content

Commit 69a4a8d

Browse files
fix(elasticsearch): override duplicate fail mixin test to match ES error type
1 parent 9280fa3 commit 69a4a8d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

integrations/elasticsearch/tests/test_document_store_async.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ async def test_delete_documents_non_existing_document_async(self, document_store
7979
with pytest.raises(DocumentStoreError):
8080
await document_store.delete_documents_async(["non_existing_id"])
8181

82+
@pytest.mark.asyncio
83+
async def test_write_documents_duplicate_fail_async(self, document_store):
84+
# Elasticsearch raises DocumentStoreError instead of DuplicateDocumentError on duplicate FAIL
85+
doc = Document(content="test doc")
86+
assert await document_store.write_documents_async([doc], policy=DuplicatePolicy.FAIL) == 1
87+
with pytest.raises(DocumentStoreError):
88+
await document_store.write_documents_async(documents=[doc], policy=DuplicatePolicy.FAIL)
89+
8290
@pytest.mark.asyncio
8391
async def test_write_documents_async(self, document_store):
8492
docs = [Document(id="1", content="test")]

0 commit comments

Comments
 (0)