add unit test for order

This commit is contained in:
Damien Elmes 2011-04-19 16:42:28 +09:00
parent 1641256da4
commit 974324e3dd
2 changed files with 24 additions and 0 deletions

View file

@ -1,5 +1,6 @@
# coding: utf-8 # coding: utf-8
from anki.db import DB
from anki.consts import * from anki.consts import *
from tests.shared import getEmptyDeck from tests.shared import getEmptyDeck

View file

@ -48,6 +48,29 @@ def test_new():
assert(stripHTML(c.q()) == qs[n]) assert(stripHTML(c.q()) == qs[n])
d.sched.answerCard(c, 2) d.sched.answerCard(c, 2)
def test_newOrder():
d = getEmptyDeck()
m = d.currentModel()
for i in range(50):
t = m.newTemplate()
t['name'] = str(i)
t['qfmt'] = "{{Front}}"
t['afmt'] = "{{Back}}"
t['actv'] = i > 25
m.addTemplate(t)
m.flush()
f = d.newFact()
f['Front'] = u'1'
f['Back'] = u'2'
# add first half
d.addFact(f)
# generate second half
d.db.execute("update cards set gid = random()")
d.qconf['newPerDay'] = 100
d.reset()
# cards should be sorted by id
assert d.sched.newQueue == list(reversed(sorted(d.sched.newQueue)))
def test_learn(): def test_learn():
d = getEmptyDeck() d = getEmptyDeck()
# add a fact # add a fact