mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00

Rather than showing the user how many cards are in the learning queue, we want to be able to show them the number of reps they have to do to clear the queue, so they can better estimate the required time. Before we were counting up with the grade column, but this means we can't quickly sum up the number of reps left. So we invert it, and count down instead. I also dropped the 'first time bonus' for now. If there's enough demand for it, it can be added back by using the flags column, instead of a dedicated cycles column.
88 lines
2.2 KiB
Python
88 lines
2.2 KiB
Python
# coding: utf-8
|
|
|
|
import time
|
|
from tests.shared import assertException, getEmptyDeck
|
|
from anki.consts import *
|
|
|
|
def test_op():
|
|
d = getEmptyDeck()
|
|
# should have no undo by default
|
|
assert not d.undoName()
|
|
# let's adjust a study option
|
|
d.save("studyopts")
|
|
d.conf['abc'] = 5
|
|
# it should be listed as undoable
|
|
assert d.undoName() == "studyopts"
|
|
# with about 5 minutes until it's clobbered
|
|
assert time.time() - d._lastSave < 1
|
|
# undoing should restore the old value
|
|
d.undo()
|
|
assert not d.undoName()
|
|
assert 'abc' not in d.conf
|
|
# an (auto)save will clear the undo
|
|
d.save("foo")
|
|
assert d.undoName() == "foo"
|
|
d.save()
|
|
assert not d.undoName()
|
|
# and a review will, too
|
|
d.save("add")
|
|
f = d.newFact()
|
|
f['Front'] = u"one"
|
|
d.addFact(f)
|
|
d.reset()
|
|
assert d.undoName() == "add"
|
|
c = d.sched.getCard()
|
|
d.sched.answerCard(c, 2)
|
|
assert d.undoName() == "Review"
|
|
|
|
def test_review():
|
|
d = getEmptyDeck()
|
|
d.conf['counts'] = COUNT_REMAINING
|
|
f = d.newFact()
|
|
f['Front'] = u"one"
|
|
d.addFact(f)
|
|
d.reset()
|
|
assert not d.undoName()
|
|
# answer
|
|
assert d.sched.counts() == (1, 0, 0)
|
|
c = d.sched.getCard()
|
|
assert c.queue == 0
|
|
d.sched.answerCard(c, 2)
|
|
assert c.left == 1
|
|
assert d.sched.counts() == (0, 1, 0)
|
|
assert c.queue == 1
|
|
# undo
|
|
assert d.undoName()
|
|
d.undo()
|
|
d.reset()
|
|
assert d.sched.counts() == (1, 0, 0)
|
|
c.load()
|
|
assert c.queue == 0
|
|
assert c.left != 1
|
|
assert not d.undoName()
|
|
# we should be able to undo multiple answers too
|
|
f['Front'] = u"two"
|
|
d.addFact(f)
|
|
d.reset()
|
|
assert d.sched.counts() == (2, 0, 0)
|
|
c = d.sched.getCard()
|
|
d.sched.answerCard(c, 2)
|
|
c = d.sched.getCard()
|
|
d.sched.answerCard(c, 2)
|
|
assert d.sched.counts() == (0, 2, 0)
|
|
d.undo()
|
|
d.reset()
|
|
assert d.sched.counts() == (1, 1, 0)
|
|
d.undo()
|
|
d.reset()
|
|
assert d.sched.counts() == (2, 0, 0)
|
|
# performing a normal op will clear the review queue
|
|
c = d.sched.getCard()
|
|
d.sched.answerCard(c, 2)
|
|
assert d.undoName() == "Review"
|
|
d.save("foo")
|
|
assert d.undoName() == "foo"
|
|
d.undo()
|
|
assert not d.undoName()
|
|
|
|
|