This commit is contained in:
team3
2026-07-12 22:41:27 +02:00
parent a9b2f5ab9e
commit 8cedcc87ec
7 changed files with 289 additions and 0 deletions

37
tests/test_lesemodus.py Normal file
View File

@@ -0,0 +1,37 @@
"""Lesemodus-Endpoints: Baustein-Karten (nicht faellig-gefiltert), Lernstand, fertig."""
import db
import main
from conftest import topic_anlegen
def _setup(topic):
b = db.insert("bausteine", topic=topic, ziel_id=1, titel="B", ord=0, status="neu")
a = db.insert("atome", topic=topic, titel="A", typ="begriff", definition="d",
status="neu", baustein_id=b, ord=0, braucht=db.j([]))
db.insert("artefakte", atom_id=a, typ="flashcard", status="verifiziert",
inhalt=db.j({"frage": "F1", "antwort": "A1"}))
db.insert("artefakte", atom_id=a, typ="flashcard", status="kandidat", # unverifiziert
inhalt=db.j({"frage": "F2", "antwort": "A2"}))
db.insert("artefakte", atom_id=a, typ="beispiel", status="verifiziert", # kein Flashcard
inhalt=db.j({"form": "text", "text": "bsp"}))
return b, a
def test_baustein_karten_nur_verifizierte_flashcards():
topic = topic_anlegen("lm1")
b, _ = _setup(topic)
karten = main.baustein_karten(topic, b)
assert len(karten) == 1 # nur die verifizierte Flashcard
assert karten[0]["inhalt"]["frage"] == "F1"
assert karten[0]["box"] == 1 # Default ohne Leitner-Eintrag
def test_lernstand_und_fertig_idempotent():
topic = topic_anlegen("lm2")
b, _ = _setup(topic)
assert main.lernstand_holen(topic) == []
main.baustein_fertig(topic, b)
assert main.lernstand_holen(topic) == [{"baustein_id": b, "status": "fertig", "xp": 0}]
main.baustein_fertig(topic, b) # zweimal → kein Duplikat
assert len(main.lernstand_holen(topic)) == 1