mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-08-30 06:27:14 +00:00
Feature: Replace Whoosh with tantivy search backend (#12471)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Antoine Mérino <3023499+Merinorus@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
Antoine Mérino
parent
e01a762e81
commit
aed9abe48c
@@ -14,6 +14,11 @@ from paperless.parsers.tesseract import RasterisedDocumentParser
|
||||
|
||||
|
||||
class TestParserSettingsFromDb(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls) -> None:
|
||||
super().setUpTestData()
|
||||
ApplicationConfiguration.objects.get_or_create()
|
||||
|
||||
@staticmethod
|
||||
def get_params():
|
||||
"""
|
||||
|
||||
@@ -2,6 +2,9 @@ import os
|
||||
from unittest import TestCase
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from paperless.settings import _get_search_language_setting
|
||||
from paperless.settings import _parse_paperless_url
|
||||
from paperless.settings import default_threads_per_worker
|
||||
|
||||
@@ -32,6 +35,48 @@ class TestThreadCalculation(TestCase):
|
||||
self.assertLessEqual(default_workers * default_threads, i)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("env_value", "expected"),
|
||||
[
|
||||
("en", "en"),
|
||||
("de", "de"),
|
||||
("fr", "fr"),
|
||||
("swedish", "swedish"),
|
||||
],
|
||||
)
|
||||
def test_get_search_language_setting_explicit_valid(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
env_value: str,
|
||||
expected: str,
|
||||
) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- PAPERLESS_SEARCH_LANGUAGE is set to a valid Tantivy stemmer language
|
||||
WHEN:
|
||||
- _get_search_language_setting is called
|
||||
THEN:
|
||||
- The explicit value is returned regardless of the OCR language
|
||||
"""
|
||||
monkeypatch.setenv("PAPERLESS_SEARCH_LANGUAGE", env_value)
|
||||
assert _get_search_language_setting("deu") == expected
|
||||
|
||||
|
||||
def test_get_search_language_setting_explicit_invalid(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- PAPERLESS_SEARCH_LANGUAGE is set to an unsupported language code
|
||||
WHEN:
|
||||
- _get_search_language_setting is called
|
||||
THEN:
|
||||
- ValueError is raised
|
||||
"""
|
||||
monkeypatch.setenv("PAPERLESS_SEARCH_LANGUAGE", "klingon")
|
||||
with pytest.raises(ValueError, match="klingon"):
|
||||
_get_search_language_setting("eng")
|
||||
|
||||
|
||||
class TestPaperlessURLSettings(TestCase):
|
||||
def test_paperless_url(self) -> None:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user