File size: 695 Bytes
ac4990e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from config import Settings
from rag_engine import DocumentChunk, RAGEngine


def test_chunking_preserves_text():
    settings = Settings(chunk_size=80, chunk_overlap=10)
    engine = RAGEngine(settings)
    text = "Alpha sentence. " * 20
    chunks = engine._chunk_text(text)
    assert len(chunks) > 1
    assert all(chunk.strip() for chunk in chunks)


def test_minmax_constant_vector():
    values = RAGEngine._minmax([3.0, 3.0, 3.0])
    assert values.tolist() == [0.0, 0.0, 0.0]


def test_retrieval_text_includes_title():
    chunk = DocumentChunk(chunk_id=0, source_id="x", title="Ada Lovelace", text="Mathematics")
    assert RAGEngine._retrieval_text(chunk).startswith("Ada Lovelace")