File size: 635 Bytes
a3ecd30 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from pathlib import Path
from app.config import Settings
from app.schemas import SourceFile
from app.services.chunker import Chunker
def test_chunker_preserves_line_ranges(tmp_path: Path):
source = tmp_path / "demo.py"
source.write_text("a = 1\nb = 2\nc = 3\n", encoding="utf-8")
source_file = SourceFile(
path="demo.py",
absolute_path=str(source),
size_bytes=source.stat().st_size,
language="Python",
)
chunks = Chunker(Settings(max_chars_per_chunk=8)).chunk_file(source_file)
assert len(chunks) > 1
assert chunks[0].line_start == 1
assert chunks[-1].line_end == 3
|