From 974324e3dd8e23dd81f13fce89d632633c0923cd Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 19 Apr 2011 16:42:28 +0900 Subject: [PATCH] add unit test for order --- tests/test_cards.py | 1 + tests/test_sched.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/test_cards.py b/tests/test_cards.py index 54f9a2c5c..134a126fd 100644 --- a/tests/test_cards.py +++ b/tests/test_cards.py @@ -1,5 +1,6 @@ # coding: utf-8 +from anki.db import DB from anki.consts import * from tests.shared import getEmptyDeck diff --git a/tests/test_sched.py b/tests/test_sched.py index e1479ad4f..e8a965943 100644 --- a/tests/test_sched.py +++ b/tests/test_sched.py @@ -48,6 +48,29 @@ def test_new(): assert(stripHTML(c.q()) == qs[n]) 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(): d = getEmptyDeck() # add a fact