fix thinko in unit tests

This commit is contained in:
Damien Elmes 2013-01-17 10:39:04 +09:00
parent 740e2425c7
commit 225f352871

View file

@ -5,9 +5,9 @@ from tests.shared import getEmptyDeck
from anki.utils import intTime from anki.utils import intTime
from anki.hooks import addHook from anki.hooks import addHook
def checkRevIvl(d, targetIvl): def checkRevIvl(d, c, targetIvl):
min, max = d.sched._fuzzIvlRange(targetIvl) min, max = d.sched._fuzzIvlRange(targetIvl)
return min <= targetIvl <= max return min <= c.ivl <= max
def test_basics(): def test_basics():
d = getEmptyDeck() d = getEmptyDeck()
@ -152,7 +152,7 @@ def test_learn():
d.sched.answerCard(c, 3) d.sched.answerCard(c, 3)
assert c.type == 2 assert c.type == 2
assert c.queue == 2 assert c.queue == 2
assert checkRevIvl(d, 4) assert checkRevIvl(d, c, 4)
# revlog should have been updated each time # revlog should have been updated each time
assert d.db.scalar("select count() from revlog where type = 0") == 5 assert d.db.scalar("select count() from revlog where type = 0") == 5
# now failed card handling # now failed card handling
@ -306,7 +306,7 @@ def test_reviews():
d.sched.answerCard(c, 2) d.sched.answerCard(c, 2)
assert c.queue == 2 assert c.queue == 2
# the new interval should be (100 + 8/4) * 1.2 = 122 # the new interval should be (100 + 8/4) * 1.2 = 122
assert checkRevIvl(d, 122) assert checkRevIvl(d, c, 122)
assert c.due == d.sched.today + c.ivl assert c.due == d.sched.today + c.ivl
# factor should have been decremented # factor should have been decremented
assert c.factor == 2350 assert c.factor == 2350
@ -319,7 +319,7 @@ def test_reviews():
c.flush() c.flush()
d.sched.answerCard(c, 3) d.sched.answerCard(c, 3)
# the new interval should be (100 + 8/2) * 2.5 = 260 # the new interval should be (100 + 8/2) * 2.5 = 260
assert checkRevIvl(d, 260) assert checkRevIvl(d, c, 260)
assert c.due == d.sched.today + c.ivl assert c.due == d.sched.today + c.ivl
# factor should have been left alone # factor should have been left alone
assert c.factor == 2500 assert c.factor == 2500
@ -329,7 +329,7 @@ def test_reviews():
c.flush() c.flush()
d.sched.answerCard(c, 4) d.sched.answerCard(c, 4)
# the new interval should be (100 + 8) * 2.5 * 1.3 = 351 # the new interval should be (100 + 8) * 2.5 * 1.3 = 351
assert checkRevIvl(d, 351) assert checkRevIvl(d, c, 351)
assert c.due == d.sched.today + c.ivl assert c.due == d.sched.today + c.ivl
# factor should have been increased # factor should have been increased
assert c.factor == 2650 assert c.factor == 2650