File size: 1,418 Bytes
2e8d6bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from src.graph.edges import after_evaluate


def _make_state(**overrides):
    base = {
        "document_path": "test.pdf",
        "chunks": ["chunk1", "chunk2"],
        "questions_asked": 5,
        "questions_correct": 3,
        "current_question": "What is X?",
        "current_answer": "X is Y.",
        "current_score": 0.8,
        "weak_chunks": [],
        "session_history": [],
        "mastery_reached": False,
    }
    base.update(overrides)
    return base


def test_low_score_triggers_reread():
    state = _make_state(current_score=0.5, weak_chunks=["c1"])
    assert after_evaluate(state) == "reread"


def test_high_score_continues_to_next_question():
    state = _make_state(current_score=0.9, questions_asked=5)
    assert after_evaluate(state) == "next_question"


def test_mastery_reached_after_min_questions():
    state = _make_state(
        current_score=0.9,
        questions_asked=10,
        questions_correct=8,
    )
    assert after_evaluate(state) == "summarize"


def test_no_mastery_if_ratio_too_low():
    state = _make_state(
        current_score=0.9,
        questions_asked=10,
        questions_correct=5,
    )
    assert after_evaluate(state) == "next_question"


def test_reread_limit_exceeded_goes_to_next():
    state = _make_state(
        current_score=0.3,
        weak_chunks=["c1", "c2", "c3", "c4"],
    )
    assert after_evaluate(state) == "next_question"