anki/pylib/tests/test_stats.py
2021-04-13 18:45:35 +10:00

38 lines
826 B
Python

# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import tempfile
from tests.shared import getEmptyCol
def test_stats():
col = getEmptyCol()
note = col.newNote()
note["Front"] = "foo"
col.addNote(note)
c = note.cards()[0]
# card stats
assert col.cardStats(c)
col.reset()
c = col.sched.getCard()
col.sched.answerCard(c, 3)
col.sched.answerCard(c, 2)
assert col.cardStats(c)
def test_graphs_empty():
col = getEmptyCol()
assert col.stats().report()
def test_graphs():
dir = tempfile.gettempdir()
col = getEmptyCol()
g = col.stats()
rep = g.report()
with open(os.path.join(dir, "test.html"), "w", encoding="UTF-8") as note:
note.write(rep)
return