fix: plug all gaps found in deep review of indexing pipeline

This commit is contained in:
CREDO23 2026-02-25 02:20:44 +02:00
parent 46c7ccd70b
commit 5b616eac5a
7 changed files with 183 additions and 6 deletions

View file

@ -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.

View 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

View file

@ -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"]