Skip to content

Fix advanced_retriever_test.py::test_index_file #46

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 13 additions & 4 deletions tests/advanced_retriever/advanced_retriever_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import tempfile
from collections import defaultdict

import orjson
import pytest

from retriv.experimental import AdvancedRetriever
Expand Down Expand Up @@ -48,6 +50,15 @@ def collection():
]


@pytest.fixture
def collection_file(collection):
with tempfile.NamedTemporaryFile(suffix=".jsonl", mode="wb") as f:
for doc in collection:
f.write(orjson.dumps(doc) + "\n".encode())
f.flush()
yield f.name


def test_check_schema_no_id():
with pytest.raises(Exception, match="Schema must contain an id field"):
AdvancedRetriever({"text": "text"})
Expand Down Expand Up @@ -582,10 +593,8 @@ def test_search_with_subset_doc_ids(collection, schema):
assert "doc_1" in res


def test_index_file(schema):
se = AdvancedRetriever(schema).index_file(
"tests/test_data/multifield_collection.jsonl"
)
def test_index_file(schema, collection_file):
se = AdvancedRetriever(schema).index_file(collection_file)

query = {
"text": "witches masses",
Expand Down