feat(chunks): aggiunge models.py con Block, Chunk, Diagnostics, ChunkingResult
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
from chunks.models import Block, Chunk, Diagnostics, ChunkingResult
|
||||
|
||||
|
||||
def test_block_creation():
|
||||
b = Block(
|
||||
id="blk_0001",
|
||||
kind="paragraph",
|
||||
content="Testo di esempio.",
|
||||
plain_text="Testo di esempio.",
|
||||
atomic=False,
|
||||
start_line=0,
|
||||
end_line=1,
|
||||
header_path=[{"level": 1, "text": "Titolo"}],
|
||||
chars=17,
|
||||
)
|
||||
assert b.id == "blk_0001"
|
||||
assert b.kind == "paragraph"
|
||||
assert not b.atomic
|
||||
assert b.chars == 17
|
||||
|
||||
|
||||
def test_chunk_creation():
|
||||
c = Chunk(
|
||||
chunk_id="chk_000001",
|
||||
chunk_index=1,
|
||||
content_original="Testo.",
|
||||
content_for_embedding="Titolo\n\nTesto.",
|
||||
content_type="section_fragment",
|
||||
chars=6,
|
||||
start_line=0,
|
||||
end_line=1,
|
||||
header_path=[{"level": 1, "text": "Titolo"}],
|
||||
block_ids=["blk_0001"],
|
||||
flags={"has_code": False, "has_table": False, "has_math": False,
|
||||
"is_overflow": False, "is_sparse": False},
|
||||
neighbors={"previous_chunk_id": None, "next_chunk_id": None},
|
||||
assets=[],
|
||||
)
|
||||
assert c.chunk_id == "chk_000001"
|
||||
assert c.assets == []
|
||||
|
||||
|
||||
def test_diagnostics_empty():
|
||||
d = Diagnostics(errors=[], warnings=[], metrics={})
|
||||
assert d.errors == []
|
||||
|
||||
|
||||
def test_chunking_result():
|
||||
r = ChunkingResult(stem="doc", source_path="sources/doc.md", chunks=[], diagnostics=Diagnostics([], [], {}))
|
||||
assert r.stem == "doc"
|
||||
assert r.chunks == []
|
||||
Reference in New Issue
Block a user