2012-12-21 08:51:59 +01:00
|
|
|
# coding: utf-8
|
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
import os
|
2019-12-25 22:00:10 +01:00
|
|
|
import tempfile
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2019-12-25 22:36:26 +01:00
|
|
|
from tests.shared import getEmptyCol
|
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
|
|
|
|
def test_stats():
|
2014-06-03 10:38:47 +02:00
|
|
|
d = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
f = d.newNote()
|
2019-12-25 05:18:34 +01:00
|
|
|
f["Front"] = "foo"
|
2012-12-21 08:51:59 +01:00
|
|
|
d.addNote(f)
|
|
|
|
c = f.cards()[0]
|
|
|
|
# card stats
|
|
|
|
assert d.cardStats(c)
|
|
|
|
d.reset()
|
|
|
|
c = d.sched.getCard()
|
|
|
|
d.sched.answerCard(c, 3)
|
|
|
|
d.sched.answerCard(c, 2)
|
|
|
|
assert d.cardStats(c)
|
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_graphs_empty():
|
2014-06-03 10:38:47 +02:00
|
|
|
d = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert d.stats().report()
|
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_graphs():
|
|
|
|
from anki import Collection as aopen
|
2019-12-25 22:36:26 +01:00
|
|
|
|
2019-12-25 22:00:10 +01:00
|
|
|
dir = tempfile.gettempdir()
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2019-12-25 22:00:10 +01:00
|
|
|
d = aopen(os.path.join(dir, "test.anki2"))
|
2012-12-21 08:51:59 +01:00
|
|
|
g = d.stats()
|
|
|
|
rep = g.report()
|
2019-12-25 22:00:10 +01:00
|
|
|
with open(os.path.join(dir, "test.html"), "w") as f:
|
2017-12-11 07:38:15 +01:00
|
|
|
f.write(rep)
|
2012-12-21 08:51:59 +01:00
|
|
|
return
|