Skip to content

Commit

Permalink
test: add test to check id_hash_keys is not ignored (#3577)
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-risch authored Nov 17, 2022
1 parent dc26e6d commit 8052632
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 11 additions & 0 deletions test/others/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,14 @@ def test_assert_span_vs_span():
assert not Span(0, 1) in Span(5, 15)
assert not Span(0, 10) in Span(5, 15)
assert not Span(10, 20) in Span(5, 15)


def test_id_hash_keys_not_ignored():
# Test that two documents with the same content but different metadata get assigned different ids if and only if
# id_hash_keys is set to 'meta'
doc1 = Document(content="hello world", meta={"doc_id": "1"}, id_hash_keys=["meta"])
doc2 = Document(content="hello world", meta={"doc_id": "2"}, id_hash_keys=["meta"])
assert doc1.id != doc2.id
doc3 = Document(content="hello world", meta={"doc_id": "3"})
doc4 = Document(content="hello world", meta={"doc_id": "4"})
assert doc3.id == doc4.id
1 change: 0 additions & 1 deletion test/others/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import numpy as np
import pytest
import pandas as pd
from pathlib import Path

import responses
from responses import matchers
Expand Down

0 comments on commit 8052632

Please sign in to comment.