23 lines
631 B
Python
23 lines
631 B
Python
"""Chunker unit tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from contract_check.core.analysis.chunker import chunk_text
|
|
|
|
|
|
def test_short_text_returns_single_chunk() -> None:
|
|
assert chunk_text("одна строка", max_chars=100) == ["одна строка"]
|
|
|
|
|
|
def test_respects_max_chars() -> None:
|
|
text = "\n".join(f"Абзац номер {i}." for i in range(500))
|
|
chunks = chunk_text(text, max_chars=100)
|
|
assert chunks
|
|
assert all(len(c) <= 100 for c in chunks)
|
|
|
|
|
|
def test_nonpositive_max_chars_raises() -> None:
|
|
with pytest.raises(ValueError):
|
|
chunk_text("abc", max_chars=0)
|