mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -05:00
more learning unit tests
This commit is contained in:
parent
96f36e66f7
commit
14c49a50cd
2 changed files with 41 additions and 7 deletions
|
|
@ -201,13 +201,13 @@ limit %d""" % self.learnLimit, lim=self.dayCutoff)
|
|||
return conf['lapse']
|
||||
|
||||
def rescheduleAsReview(self, card, conf, early):
|
||||
card.queue = 1
|
||||
card.type = 1
|
||||
if card.type == 1:
|
||||
# failed; put back entry due
|
||||
card.due = card.edue
|
||||
else:
|
||||
self.rescheduleNew(card, conf, early)
|
||||
card.queue = 1
|
||||
card.type = 1
|
||||
|
||||
def rescheduleNew(self, card, conf, early):
|
||||
if not early:
|
||||
|
|
@ -219,7 +219,8 @@ limit %d""" % self.learnLimit, lim=self.dayCutoff)
|
|||
else:
|
||||
# first time bonus
|
||||
int_ = conf['ints'][1]
|
||||
card.interval = int_
|
||||
card.ivl = int_
|
||||
card.due = self.today+int_
|
||||
card.factor = conf['initialFactor']
|
||||
|
||||
def logLearn(self, card, ease, conf, leaving):
|
||||
|
|
|
|||
|
|
@ -94,6 +94,39 @@ def test_learn():
|
|||
d.sched.answerCard(c, 2)
|
||||
assert c.queue == 1
|
||||
assert c.type == 1
|
||||
print "test intervals, check early removal, etc"
|
||||
|
||||
|
||||
# should be due tomorrow, with an interval of 1
|
||||
assert c.due == d.sched.today+1
|
||||
assert c.ivl == 1
|
||||
# let's try early removal bonus
|
||||
c.type = 2
|
||||
c.queue = 0
|
||||
c.cycles = 0
|
||||
d.sched.answerCard(c, 3)
|
||||
assert c.type == 1
|
||||
assert c.ivl == 7
|
||||
# or normal removal
|
||||
c.type = 2
|
||||
c.queue = 0
|
||||
c.cycles = 1
|
||||
d.sched.answerCard(c, 3)
|
||||
assert c.type == 1
|
||||
assert c.ivl == 4
|
||||
# revlog should have been updated each time
|
||||
d.db.scalar("select count() from revlog where type = 0") == 6
|
||||
# now failed card handling
|
||||
c.type = 1
|
||||
c.queue = 0
|
||||
c.edue = 123
|
||||
d.sched.answerCard(c, 3)
|
||||
assert c.due == 123
|
||||
assert c.type == 1
|
||||
assert c.queue == 1
|
||||
# we should be able to remove manually, too
|
||||
c.type = 1
|
||||
c.queue = 0
|
||||
c.edue = 321
|
||||
c.flush()
|
||||
d.sched.removeFailed()
|
||||
c.load()
|
||||
assert c.queue == 1
|
||||
assert c.due == 321
|
||||
|
|
|
|||
Loading…
Reference in a new issue