mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
fix: plug all gaps found in deep review of indexing pipeline
This commit is contained in:
parent
46c7ccd70b
commit
5b616eac5a
7 changed files with 183 additions and 6 deletions
|
|
@ -1,3 +0,0 @@
|
|||
# No fixtures needed for unit tests yet.
|
||||
# Unit tests cover pure functions and value objects with no dependencies.
|
||||
# External-boundary mocks (llm, embedding_model) live in tests/integration/conftest.py.
|
||||
15
surfsense_backend/tests/unit/indexing_pipeline/conftest.py
Normal file
15
surfsense_backend/tests/unit/indexing_pipeline/conftest.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def patched_chunker_instance(mocker):
|
||||
mock = mocker.patch("app.indexing_pipeline.document_chunker.config.chunker_instance")
|
||||
mock.chunk.return_value = [mocker.Mock(text="prose chunk")]
|
||||
return mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def patched_code_chunker_instance(mocker):
|
||||
mock = mocker.patch("app.indexing_pipeline.document_chunker.config.code_chunker_instance")
|
||||
mock.chunk.return_value = [mocker.Mock(text="code chunk")]
|
||||
return mock
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import pytest
|
||||
|
||||
from app.indexing_pipeline.document_chunker import chunk_text
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
def test_uses_code_chunker_when_flag_is_true(patched_code_chunker_instance):
|
||||
result = chunk_text("def foo(): pass", use_code_chunker=True)
|
||||
|
||||
patched_code_chunker_instance.chunk.assert_called_once_with("def foo(): pass")
|
||||
assert result == ["code chunk"]
|
||||
|
||||
|
||||
def test_uses_default_chunker_when_flag_is_false(patched_chunker_instance):
|
||||
result = chunk_text("Some prose text.", use_code_chunker=False)
|
||||
|
||||
patched_chunker_instance.chunk.assert_called_once_with("Some prose text.")
|
||||
assert result == ["prose chunk"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue