mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-05-15 19:15:23 +00:00
Fix: add _search_index fixture to TestDateWorkflowLocalization
Tests that create or consume documents trigger the search index signal handler, which calls get_backend().add_or_update() against settings.INDEX_DIR. This class only inherited SampleDirMixin, leaving INDEX_DIR pointing at the default non-existent path and causing FileNotFoundError in CI. Added _search_index fixture to documents/tests/conftest.py: creates a temp index directory, overrides INDEX_DIR, and resets the backend singleton. Applied via @pytest.mark.usefixtures on the class. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -92,6 +92,23 @@ def sample_doc(
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def _search_index(tmp_path: Path, settings: SettingsWrapper) -> None:
|
||||
"""Create a temp index directory and point INDEX_DIR at it.
|
||||
|
||||
Resets the backend singleton before and after so each test gets a clean
|
||||
index rather than reusing a stale singleton from another test.
|
||||
"""
|
||||
from documents.search import reset_backend
|
||||
|
||||
index_dir = tmp_path / "index"
|
||||
index_dir.mkdir()
|
||||
settings.INDEX_DIR = index_dir
|
||||
reset_backend()
|
||||
yield
|
||||
reset_backend()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def settings_timezone(settings: SettingsWrapper) -> zoneinfo.ZoneInfo:
|
||||
return zoneinfo.ZoneInfo(settings.TIME_ZONE)
|
||||
|
||||
@@ -4802,6 +4802,7 @@ class TestWebhookSecurity:
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.usefixtures("_search_index")
|
||||
class TestDateWorkflowLocalization(
|
||||
SampleDirMixin,
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user