Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test to check id_hash_keys is not ignored #3577

Merged
merged 3 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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