Chore: Move the search tests onto the shared indexing fixtures (#14159)

This commit is contained in:
Trenton H
2026-09-17 14:55:13 -07:00
committed by GitHub
parent 20d309a413
commit fdd32b73bb
24 changed files with 410 additions and 606 deletions
+23
View File
@@ -3,9 +3,12 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
import tantivy
from documents.search._backend import TantivyBackend
from documents.search._backend import reset_backend
from documents.search._schema import build_schema
from documents.search._tokenizer import register_tokenizers
from documents.tests.factories import DocumentFactory
if TYPE_CHECKING:
@@ -72,3 +75,23 @@ def matched_ids(backend: TantivyBackend) -> Callable[[str], set[int]]:
return set(backend.search_ids(query, user=None))
return _matched_ids
@pytest.fixture(scope="module")
def query_index() -> tantivy.Index:
"""An in-memory, unstemmed index for the parse-only tests.
These never index a document, so one index per module is shared
read-only across that module's tests.
"""
idx = tantivy.Index(build_schema(), path=None)
register_tokenizers(idx, "")
return idx
@pytest.fixture
def fuzzy_enabled(settings: Settings) -> None:
"""Enable the fuzzy blend clause. The threshold doubles as a minimum
score filter, so it is set to 0.0: every hit passes and the test sees
the clause's matching behaviour, not the filter's."""
settings.ADVANCED_FUZZY_SEARCH_THRESHOLD = 0.0