mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00

Like the previous change, models have been moved from a separate DB table to an entry in the deck. We need them for many operations including reviewing, and it's easier to keep them in memory than half on disk with a cache that gets cleared every time we .reset(). This means they are easily serialized as well - previously they were part Python and part JSON, which made access confusing. Because the data is all pulled from JSON now, the instance methods have been moved to the model registry. Eg: model.addField(...) -> deck.models.addField(model, ...). - IDs are now timestamped as with groups et al. - The data field for plugins was also removed. Config info can be added to deck.conf; larger data should be stored externally. - Upgrading needs to be updated for the new model structure. - HexifyID() now accepts strings as well, as our IDs get converted to strings in the serialization process.
32 lines
740 B
Python
32 lines
740 B
Python
# coding: utf-8
|
|
|
|
import time, copy, os
|
|
from tests.shared import assertException, getEmptyDeck
|
|
from anki.utils import stripHTML, intTime
|
|
from anki.hooks import addHook
|
|
|
|
def test_stats():
|
|
d = getEmptyDeck()
|
|
f = d.newFact()
|
|
f['Front'] = "foo"
|
|
d.addFact(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)
|
|
|
|
def test_graphs_empty():
|
|
d = getEmptyDeck()
|
|
assert d.stats().report()
|
|
|
|
def test_graphs():
|
|
from anki import Deck
|
|
d = Deck(os.path.expanduser("~/test.anki"))
|
|
g = d.stats()
|
|
rep = g.report()
|
|
open(os.path.expanduser("~/test.html"), "w").write(rep)
|
|
return
|