mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-01 09:44:19 +00:00
Fix: ensure index dir exists before open, fix test isolation gaps
- `open_or_rebuild_index` now calls `index_dir.mkdir(parents=True, exist_ok=True)` so a missing index directory is created on demand rather than crashing on `iterdir()` inside `wipe_index` - `TestTagHierarchy.setUp` calls `super().setUp()` so `DirectoriesMixin` runs and `self.dirs` is set before teardown tries to clean up - `test_search_more_like` d4 content changed to words with no overlap with d2/d3 to avoid spurious MLT hits from shared stop words at `min_doc_frequency=1` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -161,6 +161,7 @@ def open_or_rebuild_index(index_dir: Path | None = None) -> tantivy.Index:
|
||||
"""
|
||||
if index_dir is None:
|
||||
index_dir = settings.INDEX_DIR
|
||||
index_dir.mkdir(parents=True, exist_ok=True)
|
||||
if needs_rebuild(index_dir):
|
||||
wipe_index(index_dir)
|
||||
idx = tantivy.Index(build_schema(), path=str(index_dir))
|
||||
|
||||
@@ -768,8 +768,8 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase):
|
||||
checksum="C",
|
||||
)
|
||||
d4 = Document.objects.create(
|
||||
title="Monty Python & the Holy Grail",
|
||||
content="And now for something completely different",
|
||||
title="Quarterly Report",
|
||||
content="quarterly revenue profit margin earnings growth",
|
||||
pk=4,
|
||||
checksum="ABC",
|
||||
)
|
||||
|
||||
@@ -11,10 +11,12 @@ from documents.models import WorkflowAction
|
||||
from documents.models import WorkflowTrigger
|
||||
from documents.serialisers import TagSerializer
|
||||
from documents.signals.handlers import run_workflows
|
||||
from documents.tests.utils import DirectoriesMixin
|
||||
|
||||
|
||||
class TestTagHierarchy(APITestCase):
|
||||
class TestTagHierarchy(DirectoriesMixin, APITestCase):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
self.user = User.objects.create_superuser(username="admin")
|
||||
self.client.force_authenticate(user=self.user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user