File size: 2,475 Bytes
1f40585
 
7505a0b
1f40585
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import pytest
from pydantic import ValidationError
from ankigen.models import (
    Step,
    Subtopics,
    Topics,
    CardFront,
    CardBack,
    Card,
    CardList,
    ConceptBreakdown,
    CardGeneration,
    LearningSequence,
)


def test_step_model():
    step = Step(explanation="expl", output="out")
    assert step.explanation == "expl"
    assert step.output == "out"

    with pytest.raises(ValidationError):
        Step(explanation="expl")  # missing output


def test_subtopics_model():
    sub = Subtopics(steps=[Step(explanation="e", output="o")], result=["r1"])
    assert len(sub.steps) == 1
    assert sub.result == ["r1"]


def test_topics_model():
    topics = Topics(result=[Subtopics(steps=[], result=[])])
    assert len(topics.result) == 1


def test_card_front_model():
    cf = CardFront(question="Q?")
    assert cf.question == "Q?"
    assert CardFront().question is None


def test_card_back_model():
    cb = CardBack(answer="A", explanation="E", example="Ex")
    assert cb.answer == "A"
    assert cb.explanation == "E"
    assert cb.example == "Ex"


def test_card_model():
    cf = CardFront(question="Q")
    cb = CardBack(answer="A", explanation="E", example="Ex")
    card = Card(front=cf, back=cb, metadata={"key": "val"}, card_type="cloze")
    assert card.front.question == "Q"
    assert card.card_type == "cloze"
    assert card.metadata["key"] == "val"


def test_card_list_model():
    cf = CardFront(question="Q")
    cb = CardBack(answer="A", explanation="E", example="Ex")
    card = Card(front=cf, back=cb)
    cl = CardList(topic="test", cards=[card])
    assert cl.topic == "test"
    assert len(cl.cards) == 1


def test_concept_breakdown_model():
    cb = ConceptBreakdown(
        main_concept="C",
        prerequisites=["P"],
        learning_outcomes=["L"],
        difficulty_level="beginner",
    )
    assert cb.difficulty_level == "beginner"


def test_card_generation_model():
    cf = CardFront(question="Q")
    cb = CardBack(answer="A", explanation="E", example="Ex")
    card = Card(front=cf, back=cb)
    cg = CardGeneration(
        concept="C", thought_process="T", verification_steps=["V"], card=card
    )
    assert cg.concept == "C"
    assert cg.card.front.question == "Q"


def test_learning_sequence_model():
    ls = LearningSequence(
        topic="T",
        concepts=[],
        cards=[],
        suggested_study_order=[],
        review_recommendations=[],
    )
    assert ls.topic == "T"