2012-12-21 08:51:59 +01:00
|
|
|
# coding: utf-8
|
|
|
|
|
2013-11-25 19:23:03 +01:00
|
|
|
import copy
|
2019-12-25 22:36:26 +01:00
|
|
|
import time
|
2013-11-25 19:23:03 +01:00
|
|
|
|
2020-01-13 04:57:51 +01:00
|
|
|
from anki import hooks
|
2020-02-02 10:19:45 +01:00
|
|
|
from anki.consts import *
|
2020-02-20 03:48:46 +01:00
|
|
|
from anki.lang import without_unicode_isolation
|
2021-02-05 10:13:55 +01:00
|
|
|
from anki.schedv2 import UnburyCurrentDeck
|
2019-12-25 22:36:26 +01:00
|
|
|
from anki.utils import intTime
|
2019-12-27 12:14:52 +01:00
|
|
|
from tests.shared import getEmptyCol as getEmptyColOrig
|
|
|
|
|
|
|
|
|
|
|
|
def getEmptyCol():
|
|
|
|
col = getEmptyColOrig()
|
|
|
|
col.changeSchedulerVer(2)
|
|
|
|
return col
|
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2013-10-01 21:04:06 +02:00
|
|
|
def test_clock():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
if (col.sched.dayCutoff - intTime()) < 10 * 60:
|
2013-10-01 21:04:06 +02:00
|
|
|
raise Exception("Unit tests will fail around the day rollover.")
|
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
def checkRevIvl(col, c, targetIvl):
|
|
|
|
min, max = col.sched._fuzzIvlRange(targetIvl)
|
2013-01-17 02:39:04 +01:00
|
|
|
return min <= c.ivl <= max
|
2012-12-22 04:36:51 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_basics():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
col.reset()
|
|
|
|
assert not col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_new():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
col.reset()
|
|
|
|
assert col.sched.newCount == 0
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
|
|
|
assert col.sched.newCount == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
# fetch it
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_NEW
|
|
|
|
assert c.type == CARD_TYPE_NEW
|
2012-12-21 08:51:59 +01:00
|
|
|
# if we answer it, it should become a learn card
|
|
|
|
t = intTime()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_LRN
|
|
|
|
assert c.type == CARD_TYPE_LRN
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c.due >= t
|
2014-06-03 11:17:02 +02:00
|
|
|
|
|
|
|
# disabled for now, as the learn fudging makes this randomly fail
|
|
|
|
# # the default order should ensure siblings are not seen together, and
|
|
|
|
# # should show all cards
|
2020-07-17 05:21:12 +02:00
|
|
|
# m = col.models.current(); mm = col.models
|
2014-06-03 11:17:02 +02:00
|
|
|
# t = mm.newTemplate("Reverse")
|
|
|
|
# t['qfmt'] = "{{Back}}"
|
|
|
|
# t['afmt'] = "{{Front}}"
|
|
|
|
# mm.addTemplate(m, t)
|
|
|
|
# mm.save(m)
|
2020-07-17 05:21:12 +02:00
|
|
|
# note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
# note['Front'] = u"2"; note['Back'] = u"2"
|
2020-07-17 05:21:12 +02:00
|
|
|
# col.addNote(note)
|
|
|
|
# note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
# note['Front'] = u"3"; note['Back'] = u"3"
|
2020-07-17 05:21:12 +02:00
|
|
|
# col.addNote(note)
|
|
|
|
# col.reset()
|
2014-06-03 11:17:02 +02:00
|
|
|
# qs = ("2", "3", "2", "3")
|
|
|
|
# for n in range(4):
|
2020-07-17 05:21:12 +02:00
|
|
|
# c = col.sched.getCard()
|
2014-06-03 11:17:02 +02:00
|
|
|
# assert qs[n] in c.q()
|
2020-07-17 05:21:12 +02:00
|
|
|
# col.sched.answerCard(c, 2)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_newLimits():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add some notes
|
2020-07-17 05:23:33 +02:00
|
|
|
deck2 = col.decks.id("Default::foo")
|
2012-12-21 08:51:59 +01:00
|
|
|
for i in range(30):
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = str(i)
|
2012-12-21 08:51:59 +01:00
|
|
|
if i > 4:
|
2020-07-17 05:23:33 +02:00
|
|
|
note.model()["did"] = deck2
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# give the child deck a different configuration
|
2020-07-17 05:21:12 +02:00
|
|
|
c2 = col.decks.add_config_returning_id("new conf")
|
2020-07-17 05:23:33 +02:00
|
|
|
col.decks.setConf(col.decks.get(deck2), c2)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# both confs have defaulted to a limit of 20
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.newCount == 20
|
2012-12-21 08:51:59 +01:00
|
|
|
# first card we get comes from parent
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c.did == 1
|
|
|
|
# limit the parent to 10 cards, meaning we get 10 in total
|
2020-07-17 05:21:12 +02:00
|
|
|
conf1 = col.decks.confForDid(1)
|
2019-12-25 05:18:34 +01:00
|
|
|
conf1["new"]["perDay"] = 10
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf1)
|
|
|
|
col.reset()
|
|
|
|
assert col.sched.newCount == 10
|
2012-12-21 08:51:59 +01:00
|
|
|
# if we limit child to 4, we should get 9
|
2020-07-17 05:23:33 +02:00
|
|
|
conf2 = col.decks.confForDid(deck2)
|
2019-12-25 05:18:34 +01:00
|
|
|
conf2["new"]["perDay"] = 4
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf2)
|
|
|
|
col.reset()
|
|
|
|
assert col.sched.newCount == 9
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_newBoxes():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
conf = col.sched._cardConf(c)
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["new"]["delays"] = [1, 2, 3, 4, 5]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
|
|
|
col.sched.answerCard(c, 2)
|
2012-12-21 08:51:59 +01:00
|
|
|
# should handle gracefully
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["new"]["delays"] = [1]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
|
|
|
col.sched.answerCard(c, 2)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_learn():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-19 10:58:40 +02:00
|
|
|
col.addNote(note)
|
2020-10-15 08:22:23 +02:00
|
|
|
# set as a new card and rebuild queues
|
|
|
|
col.db.execute(f"update cards set queue={QUEUE_TYPE_NEW}, type={CARD_TYPE_NEW}")
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# sched.getCard should return it, since it's due in the past
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c
|
2020-07-17 05:21:12 +02:00
|
|
|
conf = col.sched._cardConf(c)
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["new"]["delays"] = [0.5, 3, 10]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
2012-12-21 08:51:59 +01:00
|
|
|
# fail it
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
# it should have three reps left to graduation
|
2019-12-25 05:18:34 +01:00
|
|
|
assert c.left % 1000 == 3
|
2020-07-19 11:24:58 +02:00
|
|
|
# it should be due in 30 seconds
|
2012-12-21 08:51:59 +01:00
|
|
|
t = round(c.due - time.time())
|
|
|
|
assert t >= 25 and t <= 40
|
|
|
|
# pass it once
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2020-07-19 11:24:58 +02:00
|
|
|
# it should be due in 3 minutes
|
2018-07-28 05:49:04 +02:00
|
|
|
dueIn = c.due - time.time()
|
2020-03-27 06:52:35 +01:00
|
|
|
assert 178 <= dueIn <= 180 * 1.25
|
2019-12-25 05:18:34 +01:00
|
|
|
assert c.left % 1000 == 2
|
2012-12-21 08:51:59 +01:00
|
|
|
# check log is accurate
|
2020-07-17 05:21:12 +02:00
|
|
|
log = col.db.first("select * from revlog order by id desc")
|
2017-12-23 01:45:56 +01:00
|
|
|
assert log[3] == 3
|
2012-12-21 08:51:59 +01:00
|
|
|
assert log[4] == -180
|
|
|
|
assert log[5] == -30
|
|
|
|
# pass again
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2020-07-19 11:24:58 +02:00
|
|
|
# it should be due in 10 minutes
|
2018-07-28 05:49:04 +02:00
|
|
|
dueIn = c.due - time.time()
|
2019-12-25 05:18:34 +01:00
|
|
|
assert 599 <= dueIn <= 600 * 1.25
|
|
|
|
assert c.left % 1000 == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
# the next pass should graduate the card
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_LRN
|
|
|
|
assert c.type == CARD_TYPE_LRN
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_REV
|
|
|
|
assert c.type == CARD_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
# should be due tomorrow, with an interval of 1
|
2020-07-17 05:21:12 +02:00
|
|
|
assert c.due == col.sched.today + 1
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c.ivl == 1
|
|
|
|
# or normal removal
|
2020-07-19 05:27:31 +02:00
|
|
|
c.type = CARD_TYPE_NEW
|
|
|
|
c.queue = QUEUE_TYPE_LRN
|
2021-02-20 05:00:26 +01:00
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 4)
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.type == CARD_TYPE_REV
|
|
|
|
assert c.queue == QUEUE_TYPE_REV
|
2020-07-17 05:21:12 +02:00
|
|
|
assert checkRevIvl(col, c, 4)
|
2012-12-21 08:51:59 +01:00
|
|
|
# revlog should have been updated each time
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.db.scalar("select count() from revlog where type = 0") == 5
|
2017-12-23 01:45:56 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2017-12-23 01:45:56 +01:00
|
|
|
def test_relearn():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2017-12-23 01:45:56 +01:00
|
|
|
c.ivl = 100
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = CARD_TYPE_REV
|
|
|
|
c.type = QUEUE_TYPE_REV
|
2017-12-23 01:45:56 +01:00
|
|
|
c.flush()
|
|
|
|
|
|
|
|
# fail the card
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_LRN
|
2020-01-31 05:38:39 +01:00
|
|
|
assert c.type == CARD_TYPE_RELEARNING
|
2017-12-23 01:45:56 +01:00
|
|
|
assert c.ivl == 1
|
|
|
|
|
|
|
|
# immediately graduate it
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 4)
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
2019-12-09 04:00:15 +01:00
|
|
|
assert c.ivl == 2
|
2020-07-17 05:21:12 +02:00
|
|
|
assert c.due == col.sched.today + c.ivl
|
2017-12-23 01:45:56 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2018-02-02 05:30:53 +01:00
|
|
|
def test_relearn_no_steps():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2018-02-02 05:30:53 +01:00
|
|
|
c.ivl = 100
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = CARD_TYPE_REV
|
|
|
|
c.type = QUEUE_TYPE_REV
|
2018-02-02 05:30:53 +01:00
|
|
|
c.flush()
|
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
conf = col.decks.confForDid(1)
|
2019-12-25 05:18:34 +01:00
|
|
|
conf["lapse"]["delays"] = []
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
2018-02-02 05:30:53 +01:00
|
|
|
|
|
|
|
# fail the card
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
2018-02-02 05:30:53 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_learn_collapsed():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add 2 notes
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "1"
|
2020-07-19 10:58:40 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "2"
|
2020-07-19 10:58:40 +02:00
|
|
|
col.addNote(note)
|
2020-10-15 08:22:23 +02:00
|
|
|
# set as a new card and rebuild queues
|
|
|
|
col.db.execute(f"update cards set queue={QUEUE_TYPE_NEW}, type={CARD_TYPE_NEW}")
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# should get '1' first
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c.q().endswith("1")
|
|
|
|
# pass it so it's due in 10 minutes
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
# get the other card
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c.q().endswith("2")
|
|
|
|
# fail it so it's due in 1 minute
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
# we shouldn't get the same card again
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert not c.q().endswith("2")
|
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_learn_day():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-19 10:58:40 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
conf = col.sched._cardConf(c)
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["new"]["delays"] = [1, 10, 1440, 2880]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
2012-12-21 08:51:59 +01:00
|
|
|
# pass it
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
# two reps to graduate, 1 more today
|
2019-12-25 05:18:34 +01:00
|
|
|
assert c.left % 1000 == 3
|
|
|
|
assert c.left // 1000 == 1
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
c = col.sched.getCard()
|
|
|
|
ni = col.sched.nextIvl
|
2017-12-23 01:45:56 +01:00
|
|
|
assert ni(c, 3) == 86400
|
2012-12-21 08:51:59 +01:00
|
|
|
# answering it will place it in queue 3
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
|
|
|
assert c.due == col.sched.today + 1
|
2020-01-31 05:38:39 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_DAY_LEARN_RELEARN
|
2020-07-17 05:21:12 +02:00
|
|
|
assert not col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
# for testing, move it back a day
|
|
|
|
c.due -= 1
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
# nextIvl should work
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 3) == 86400 * 2
|
2012-12-21 08:51:59 +01:00
|
|
|
# if we fail it, it should be back in the correct queue
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_LRN
|
2020-07-17 05:21:12 +02:00
|
|
|
col.undo()
|
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
# simulate the passing of another two days
|
|
|
|
c.due -= 2
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# the last pass should graduate it into a review card
|
2017-12-23 01:45:56 +01:00
|
|
|
assert ni(c, 3) == 86400
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
# if the lapse step is tomorrow, failing it should handle the counts
|
|
|
|
# correctly
|
|
|
|
c.due = 0
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (0, 0, 1)
|
|
|
|
conf = col.sched._cardConf(c)
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["lapse"]["delays"] = [1440]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
2020-01-31 05:38:39 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_DAY_LEARN_RELEARN
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.counts() == (0, 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_reviews():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# set the card up as a review card, due 8 days ago
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
|
|
|
c.queue = QUEUE_TYPE_REV
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today - 8
|
2017-02-08 08:28:05 +01:00
|
|
|
c.factor = STARTING_FACTOR
|
2012-12-21 08:51:59 +01:00
|
|
|
c.reps = 3
|
|
|
|
c.lapses = 1
|
|
|
|
c.ivl = 100
|
|
|
|
c.startTimer()
|
|
|
|
c.flush()
|
|
|
|
# save it for later use as well
|
|
|
|
cardcopy = copy.copy(c)
|
2017-12-23 01:45:56 +01:00
|
|
|
# try with an ease of 2
|
2012-12-21 08:51:59 +01:00
|
|
|
##################################################
|
|
|
|
c = copy.copy(cardcopy)
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
col.sched.answerCard(c, 2)
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_REV
|
2018-06-01 04:24:11 +02:00
|
|
|
# the new interval should be (100) * 1.2 = 120
|
2020-07-17 05:21:12 +02:00
|
|
|
assert checkRevIvl(col, c, 120)
|
|
|
|
assert c.due == col.sched.today + c.ivl
|
2012-12-21 08:51:59 +01:00
|
|
|
# factor should have been decremented
|
|
|
|
assert c.factor == 2350
|
|
|
|
# check counters
|
|
|
|
assert c.lapses == 1
|
|
|
|
assert c.reps == 4
|
|
|
|
# ease 3
|
|
|
|
##################################################
|
|
|
|
c = copy.copy(cardcopy)
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
# the new interval should be (100 + 8/2) * 2.5 = 260
|
2020-07-17 05:21:12 +02:00
|
|
|
assert checkRevIvl(col, c, 260)
|
|
|
|
assert c.due == col.sched.today + c.ivl
|
2012-12-21 08:51:59 +01:00
|
|
|
# factor should have been left alone
|
2017-02-08 08:28:05 +01:00
|
|
|
assert c.factor == STARTING_FACTOR
|
2012-12-21 08:51:59 +01:00
|
|
|
# ease 4
|
|
|
|
##################################################
|
|
|
|
c = copy.copy(cardcopy)
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 4)
|
2012-12-21 08:51:59 +01:00
|
|
|
# the new interval should be (100 + 8) * 2.5 * 1.3 = 351
|
2020-07-17 05:21:12 +02:00
|
|
|
assert checkRevIvl(col, c, 351)
|
|
|
|
assert c.due == col.sched.today + c.ivl
|
2012-12-21 08:51:59 +01:00
|
|
|
# factor should have been increased
|
|
|
|
assert c.factor == 2650
|
|
|
|
# leech handling
|
|
|
|
##################################################
|
2020-07-17 05:21:12 +02:00
|
|
|
conf = col.decks.getConf(1)
|
2020-06-09 06:11:46 +02:00
|
|
|
conf["lapse"]["leechAction"] = LEECH_SUSPEND
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
2012-12-21 08:51:59 +01:00
|
|
|
c = copy.copy(cardcopy)
|
|
|
|
c.lapses = 7
|
|
|
|
c.flush()
|
2020-07-20 06:28:36 +02:00
|
|
|
# setup hook
|
2012-12-21 08:51:59 +01:00
|
|
|
hooked = []
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def onLeech(card):
|
|
|
|
hooked.append(1)
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2020-01-15 07:53:24 +01:00
|
|
|
hooks.card_did_leech.append(onLeech)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
assert hooked
|
2020-01-31 04:48:14 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_SUSPENDED
|
2012-12-21 08:51:59 +01:00
|
|
|
c.load()
|
2020-01-31 04:48:14 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_SUSPENDED
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2017-12-29 01:28:37 +01:00
|
|
|
def test_review_limits():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2017-12-29 01:28:37 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
parent = col.decks.get(col.decks.id("parent"))
|
|
|
|
child = col.decks.get(col.decks.id("parent::child"))
|
2017-12-29 01:28:37 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
pconf = col.decks.get_config(col.decks.add_config_returning_id("parentConf"))
|
|
|
|
cconf = col.decks.get_config(col.decks.add_config_returning_id("childConf"))
|
2017-12-29 01:28:37 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
pconf["rev"]["perDay"] = 5
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.update_config(pconf)
|
|
|
|
col.decks.setConf(parent, pconf["id"])
|
2019-12-25 05:18:34 +01:00
|
|
|
cconf["rev"]["perDay"] = 10
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.update_config(cconf)
|
|
|
|
col.decks.setConf(child, cconf["id"])
|
2017-12-29 01:28:37 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
m = col.models.current()
|
2019-12-25 05:18:34 +01:00
|
|
|
m["did"] = child["id"]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.models.save(m, updateReqs=False)
|
2017-12-29 01:28:37 +01:00
|
|
|
|
|
|
|
# add some cards
|
|
|
|
for i in range(20):
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2017-12-29 01:28:37 +01:00
|
|
|
|
|
|
|
# make them reviews
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = CARD_TYPE_REV
|
|
|
|
c.type = QUEUE_TYPE_REV
|
2017-12-29 01:28:37 +01:00
|
|
|
c.due = 0
|
|
|
|
c.flush()
|
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
tree = col.sched.deck_due_tree().children
|
2020-05-15 13:21:10 +02:00
|
|
|
# (('parent', 1514457677462, 5, 0, 0, (('child', 1514457677463, 5, 0, 0, ()),)))
|
2020-05-16 04:10:40 +02:00
|
|
|
assert tree[0].review_count == 5 # parent
|
|
|
|
assert tree[0].children[0].review_count == 5 # child
|
2017-12-29 01:28:37 +01:00
|
|
|
|
|
|
|
# .counts() should match
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.select(child["id"])
|
|
|
|
col.sched.reset()
|
|
|
|
assert col.sched.counts() == (0, 0, 5)
|
2017-12-29 01:28:37 +01:00
|
|
|
|
|
|
|
# answering a card in the child should decrement parent count
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 3)
|
|
|
|
assert col.sched.counts() == (0, 0, 4)
|
2017-12-29 01:28:37 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
tree = col.sched.deck_due_tree().children
|
2020-05-16 04:10:40 +02:00
|
|
|
assert tree[0].review_count == 4 # parent
|
|
|
|
assert tree[0].children[0].review_count == 4 # child
|
2017-12-29 01:28:37 +01:00
|
|
|
|
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_button_spacing():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# 1 day ivl review card due now
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
|
|
|
c.queue = QUEUE_TYPE_REV
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today
|
2012-12-21 08:51:59 +01:00
|
|
|
c.reps = 1
|
|
|
|
c.ivl = 1
|
|
|
|
c.startTimer()
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
ni = col.sched.nextIvlStr
|
2020-02-20 03:48:46 +01:00
|
|
|
wo = without_unicode_isolation
|
|
|
|
assert wo(ni(c, 2)) == "2d"
|
|
|
|
assert wo(ni(c, 3)) == "3d"
|
|
|
|
assert wo(ni(c, 4)) == "4d"
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2018-07-11 13:23:22 +02:00
|
|
|
# if hard factor is <= 1, then hard may not increase
|
2020-07-17 05:21:12 +02:00
|
|
|
conf = col.decks.confForDid(1)
|
2019-12-25 05:18:34 +01:00
|
|
|
conf["rev"]["hardFactor"] = 1
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
2020-02-20 03:48:46 +01:00
|
|
|
assert wo(ni(c, 2)) == "1d"
|
2018-07-11 13:23:22 +02:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_overdue_lapse():
|
|
|
|
# disabled in commit 3069729776990980f34c25be66410e947e9d51a2
|
|
|
|
return
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol() # pylint: disable=unreachable
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# simulate a review that was lapsed and is now due for its normal review
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
2020-07-19 05:27:31 +02:00
|
|
|
c.queue = QUEUE_TYPE_LRN
|
2012-12-21 08:51:59 +01:00
|
|
|
c.due = -1
|
|
|
|
c.odue = -1
|
2017-02-08 08:28:05 +01:00
|
|
|
c.factor = STARTING_FACTOR
|
2012-12-21 08:51:59 +01:00
|
|
|
c.left = 2002
|
|
|
|
c.ivl = 0
|
|
|
|
c.flush()
|
|
|
|
# checkpoint
|
2020-07-17 05:21:12 +02:00
|
|
|
col.save()
|
|
|
|
col.sched.reset()
|
|
|
|
assert col.sched.counts() == (0, 2, 0)
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
# it should be due tomorrow
|
2020-07-17 05:21:12 +02:00
|
|
|
assert c.due == col.sched.today + 1
|
2012-12-21 08:51:59 +01:00
|
|
|
# revert to before
|
2020-07-17 05:21:12 +02:00
|
|
|
col.rollback()
|
2012-12-21 08:51:59 +01:00
|
|
|
# with the default settings, the overdue card should be removed from the
|
|
|
|
# learning queue
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.reset()
|
|
|
|
assert col.sched.counts() == (0, 0, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_nextIvl():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
|
|
|
conf = col.decks.confForDid(1)
|
2019-12-25 05:18:34 +01:00
|
|
|
conf["new"]["delays"] = [0.5, 3, 10]
|
|
|
|
conf["lapse"]["delays"] = [1, 5, 9]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
# new cards
|
|
|
|
##################################################
|
2020-07-17 05:21:12 +02:00
|
|
|
ni = col.sched.nextIvl
|
2012-12-21 08:51:59 +01:00
|
|
|
assert ni(c, 1) == 30
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 2) == (30 + 180) // 2
|
2017-12-23 01:45:56 +01:00
|
|
|
assert ni(c, 3) == 180
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 4) == 4 * 86400
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
# cards in learning
|
|
|
|
##################################################
|
|
|
|
assert ni(c, 1) == 30
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 2) == (30 + 180) // 2
|
2017-12-23 01:45:56 +01:00
|
|
|
assert ni(c, 3) == 180
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 4) == 4 * 86400
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
assert ni(c, 1) == 30
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 2) == (180 + 600) // 2
|
2017-12-23 01:45:56 +01:00
|
|
|
assert ni(c, 3) == 600
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 4) == 4 * 86400
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
# normal graduation is tomorrow
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 3) == 1 * 86400
|
|
|
|
assert ni(c, 4) == 4 * 86400
|
2012-12-21 08:51:59 +01:00
|
|
|
# lapsed cards
|
|
|
|
##################################################
|
2021-02-20 05:00:26 +01:00
|
|
|
c.type = CARD_TYPE_RELEARNING
|
2012-12-21 08:51:59 +01:00
|
|
|
c.ivl = 100
|
2017-02-08 08:28:05 +01:00
|
|
|
c.factor = STARTING_FACTOR
|
2021-02-20 05:00:26 +01:00
|
|
|
c.flush()
|
2012-12-21 08:51:59 +01:00
|
|
|
assert ni(c, 1) == 60
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 3) == 100 * 86400
|
|
|
|
assert ni(c, 4) == 101 * 86400
|
2012-12-21 08:51:59 +01:00
|
|
|
# review cards
|
|
|
|
##################################################
|
2021-02-20 05:00:26 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = QUEUE_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
c.ivl = 100
|
2017-02-08 08:28:05 +01:00
|
|
|
c.factor = STARTING_FACTOR
|
2021-02-20 05:00:26 +01:00
|
|
|
c.flush()
|
2012-12-21 08:51:59 +01:00
|
|
|
# failing it should put it at 60s
|
|
|
|
assert ni(c, 1) == 60
|
|
|
|
# or 1 day if relearn is false
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["lapse"]["delays"] = []
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
2019-12-25 05:18:34 +01:00
|
|
|
assert ni(c, 1) == 1 * 86400
|
2012-12-21 08:51:59 +01:00
|
|
|
# (* 100 1.2 86400)10368000.0
|
|
|
|
assert ni(c, 2) == 10368000
|
|
|
|
# (* 100 2.5 86400)21600000.0
|
|
|
|
assert ni(c, 3) == 21600000
|
|
|
|
# (* 100 2.5 1.3 86400)28080000.0
|
|
|
|
assert ni(c, 4) == 28080000
|
2020-07-17 05:21:12 +02:00
|
|
|
assert without_unicode_isolation(col.sched.nextIvlStr(c, 4)) == "10.8mo"
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2017-12-27 06:17:53 +01:00
|
|
|
def test_bury():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c2 = note.cards()[0]
|
2012-12-21 08:51:59 +01:00
|
|
|
# burying
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.bury_cards([c.id], manual=True) # pylint: disable=unexpected-keyword-arg
|
2017-12-27 06:17:53 +01:00
|
|
|
c.load()
|
2020-01-31 04:21:20 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_MANUALLY_BURIED
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.bury_cards(
|
|
|
|
[c2.id], manual=False
|
|
|
|
) # pylint: disable=unexpected-keyword-arg
|
2017-12-27 06:17:53 +01:00
|
|
|
c2.load()
|
2020-01-31 04:40:51 +01:00
|
|
|
assert c2.queue == QUEUE_TYPE_SIBLING_BURIED
|
2017-12-27 06:17:53 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert not col.sched.getCard()
|
2017-12-27 06:17:53 +01:00
|
|
|
|
2021-02-05 10:13:55 +01:00
|
|
|
col.sched.unbury_cards_in_current_deck(UnburyCurrentDeck.USER_ONLY)
|
2019-12-25 05:18:34 +01:00
|
|
|
c.load()
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_NEW
|
2019-12-25 05:18:34 +01:00
|
|
|
c2.load()
|
2020-01-31 04:40:51 +01:00
|
|
|
assert c2.queue == QUEUE_TYPE_SIBLING_BURIED
|
2017-12-27 06:17:53 +01:00
|
|
|
|
2021-02-05 10:13:55 +01:00
|
|
|
col.sched.unbury_cards_in_current_deck(UnburyCurrentDeck.SCHED_ONLY)
|
2019-12-25 05:18:34 +01:00
|
|
|
c2.load()
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c2.queue == QUEUE_TYPE_NEW
|
2017-12-27 06:17:53 +01:00
|
|
|
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.bury_cards([c.id, c2.id])
|
2020-08-29 14:02:22 +02:00
|
|
|
col.sched.unbury_cards_in_current_deck()
|
2017-12-27 06:17:53 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2017-12-27 06:17:53 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.counts() == (2, 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_suspend():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2012-12-21 08:51:59 +01:00
|
|
|
# suspending
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.getCard()
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.suspend_cards([c.id])
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert not col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
# unsuspending
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.unsuspend_cards([c.id])
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
# should cope with rev cards being relearnt
|
2019-12-25 05:18:34 +01:00
|
|
|
c.due = 0
|
|
|
|
c.ivl = 100
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
|
|
|
c.queue = QUEUE_TYPE_REV
|
2019-12-25 05:18:34 +01:00
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c.due >= time.time()
|
2017-12-26 13:32:25 +01:00
|
|
|
due = c.due
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_LRN
|
2020-01-31 05:38:39 +01:00
|
|
|
assert c.type == CARD_TYPE_RELEARNING
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.suspend_cards([c.id])
|
|
|
|
col.sched.unsuspend_cards([c.id])
|
2012-12-21 08:51:59 +01:00
|
|
|
c.load()
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_LRN
|
2020-01-31 05:38:39 +01:00
|
|
|
assert c.type == CARD_TYPE_RELEARNING
|
2017-12-26 13:32:25 +01:00
|
|
|
assert c.due == due
|
2012-12-21 08:51:59 +01:00
|
|
|
# should cope with cards in cram decks
|
|
|
|
c.due = 1
|
|
|
|
c.flush()
|
2020-09-03 10:02:47 +02:00
|
|
|
did = col.decks.new_filtered("tmp")
|
|
|
|
col.sched.rebuild_filtered_deck(did)
|
2012-12-21 08:51:59 +01:00
|
|
|
c.load()
|
|
|
|
assert c.due != 1
|
|
|
|
assert c.did != 1
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.suspend_cards([c.id])
|
2012-12-21 08:51:59 +01:00
|
|
|
c.load()
|
2017-12-26 13:32:25 +01:00
|
|
|
assert c.due != 1
|
|
|
|
assert c.did != 1
|
|
|
|
assert c.odue == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2017-12-23 01:45:56 +01:00
|
|
|
def test_filt_reviewing_early_normal():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2012-12-21 08:51:59 +01:00
|
|
|
c.ivl = 100
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = CARD_TYPE_REV
|
|
|
|
c.type = QUEUE_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
# due in 25 days, so it's been waiting 75 days
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today + 25
|
2012-12-21 08:51:59 +01:00
|
|
|
c.mod = 1
|
2017-02-08 08:28:05 +01:00
|
|
|
c.factor = STARTING_FACTOR
|
2012-12-21 08:51:59 +01:00
|
|
|
c.startTimer()
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (0, 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
# create a dynamic deck and refresh it
|
2020-09-03 10:02:47 +02:00
|
|
|
did = col.decks.new_filtered("Cram")
|
|
|
|
col.sched.rebuild_filtered_deck(did)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2017-12-24 10:27:19 +01:00
|
|
|
# should appear as normal in the deck list
|
2020-07-17 05:21:12 +02:00
|
|
|
assert sorted(col.sched.deck_due_tree().children)[0].review_count == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
# and should appear in the counts
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.counts() == (0, 0, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
# grab it and check estimates
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
|
|
|
assert col.sched.answerButtons(c) == 4
|
|
|
|
assert col.sched.nextIvl(c, 1) == 600
|
|
|
|
assert col.sched.nextIvl(c, 2) == int(75 * 1.2) * 86400
|
|
|
|
assert col.sched.nextIvl(c, 3) == int(75 * 2.5) * 86400
|
|
|
|
assert col.sched.nextIvl(c, 4) == int(75 * 2.5 * 1.15) * 86400
|
2017-12-23 01:45:56 +01:00
|
|
|
|
|
|
|
# answer 'good'
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
|
|
|
checkRevIvl(col, c, 90)
|
|
|
|
assert c.due == col.sched.today + c.ivl
|
2017-12-23 01:45:56 +01:00
|
|
|
assert not c.odue
|
|
|
|
# should not be in learning
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
# should be logged as a cram rep
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.db.scalar("select type from revlog order by id desc limit 1") == 3
|
2017-12-23 01:45:56 +01:00
|
|
|
|
|
|
|
# due in 75 days, so it's been waiting 25 days
|
2012-12-21 08:51:59 +01:00
|
|
|
c.ivl = 100
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today + 75
|
2012-12-21 08:51:59 +01:00
|
|
|
c.flush()
|
2020-09-03 10:02:47 +02:00
|
|
|
col.sched.rebuild_filtered_deck(did)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.nextIvl(c, 2) == 60 * 86400
|
|
|
|
assert col.sched.nextIvl(c, 3) == 100 * 86400
|
|
|
|
assert col.sched.nextIvl(c, 4) == 114 * 86400
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2017-12-23 01:45:56 +01:00
|
|
|
|
|
|
|
def test_filt_keep_lrn_state():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2019-05-31 07:02:58 +02:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2017-12-23 01:45:56 +01:00
|
|
|
|
|
|
|
# fail the card outside filtered deck
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
|
|
|
conf = col.sched._cardConf(c)
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["new"]["delays"] = [1, 10, 61]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
2019-05-31 07:02:58 +02:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2017-12-23 01:45:56 +01:00
|
|
|
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
2021-02-20 04:59:07 +01:00
|
|
|
assert c.left % 1000 == 3
|
2019-05-31 07:02:58 +02:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
2017-12-23 01:45:56 +01:00
|
|
|
|
|
|
|
# create a dynamic deck and refresh it
|
2020-09-03 10:02:47 +02:00
|
|
|
did = col.decks.new_filtered("Cram")
|
|
|
|
col.sched.rebuild_filtered_deck(did)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2017-12-23 01:45:56 +01:00
|
|
|
|
|
|
|
# card should still be in learning state
|
|
|
|
c.load()
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
2021-02-20 04:59:07 +01:00
|
|
|
assert c.left % 1000 == 2
|
2019-05-31 07:02:58 +02:00
|
|
|
|
|
|
|
# should be able to advance learning steps
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2019-05-31 07:02:58 +02:00
|
|
|
# should be due at least an hour in the future
|
2019-12-25 05:18:34 +01:00
|
|
|
assert c.due - intTime() > 60 * 60
|
2017-12-23 01:45:56 +01:00
|
|
|
|
|
|
|
# emptying the deck preserves learning state
|
2020-09-03 09:43:07 +02:00
|
|
|
col.sched.empty_filtered_deck(did)
|
2012-12-21 08:51:59 +01:00
|
|
|
c.load()
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
2021-02-20 04:59:07 +01:00
|
|
|
assert c.left % 1000 == 1
|
2019-12-25 05:18:34 +01:00
|
|
|
assert c.due - intTime() > 60 * 60
|
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2017-12-26 12:46:49 +01:00
|
|
|
def test_preview():
|
|
|
|
# add cards
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2017-12-26 12:46:49 +01:00
|
|
|
orig = copy.copy(c)
|
2020-07-17 05:21:12 +02:00
|
|
|
note2 = col.newNote()
|
2020-07-17 05:18:35 +02:00
|
|
|
note2["Front"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note2)
|
2012-12-21 08:51:59 +01:00
|
|
|
# cram deck
|
2020-09-03 10:02:47 +02:00
|
|
|
did = col.decks.new_filtered("Cram")
|
2020-07-17 05:21:12 +02:00
|
|
|
cram = col.decks.get(did)
|
2019-12-25 05:18:34 +01:00
|
|
|
cram["resched"] = False
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(cram)
|
2020-09-03 10:02:47 +02:00
|
|
|
col.sched.rebuild_filtered_deck(did)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2017-12-26 12:46:49 +01:00
|
|
|
# grab the first card
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
|
|
|
assert col.sched.answerButtons(c) == 2
|
|
|
|
assert col.sched.nextIvl(c, 1) == 600
|
|
|
|
assert col.sched.nextIvl(c, 2) == 0
|
2017-12-26 12:46:49 +01:00
|
|
|
# failing it will push its due time back
|
|
|
|
due = c.due
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2017-12-26 12:46:49 +01:00
|
|
|
assert c.due != due
|
|
|
|
|
|
|
|
# the other card should come next
|
2020-07-17 05:21:12 +02:00
|
|
|
c2 = col.sched.getCard()
|
2017-12-26 12:46:49 +01:00
|
|
|
assert c2.id != c.id
|
|
|
|
|
|
|
|
# passing it will remove it
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c2, 2)
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c2.queue == QUEUE_TYPE_NEW
|
2017-12-26 13:32:25 +01:00
|
|
|
assert c2.reps == 0
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c2.type == CARD_TYPE_NEW
|
2017-12-26 12:46:49 +01:00
|
|
|
|
|
|
|
# the other card should appear again
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2017-12-26 12:46:49 +01:00
|
|
|
assert c.id == orig.id
|
|
|
|
|
2017-12-26 13:32:25 +01:00
|
|
|
# emptying the filtered deck should restore card
|
2020-09-03 09:43:07 +02:00
|
|
|
col.sched.empty_filtered_deck(did)
|
2017-12-26 13:32:25 +01:00
|
|
|
c.load()
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_NEW
|
2017-12-26 12:46:49 +01:00
|
|
|
assert c.reps == 0
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c.type == CARD_TYPE_NEW
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_ordcycle():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add two more templates and set second active
|
2020-07-17 05:21:12 +02:00
|
|
|
m = col.models.current()
|
|
|
|
mm = col.models
|
2012-12-21 08:51:59 +01:00
|
|
|
t = mm.newTemplate("Reverse")
|
2019-12-25 05:18:34 +01:00
|
|
|
t["qfmt"] = "{{Back}}"
|
|
|
|
t["afmt"] = "{{Front}}"
|
2012-12-21 08:51:59 +01:00
|
|
|
mm.addTemplate(m, t)
|
|
|
|
t = mm.newTemplate("f2")
|
2019-12-25 05:18:34 +01:00
|
|
|
t["qfmt"] = "{{Front}}"
|
|
|
|
t["afmt"] = "{{Back}}"
|
2012-12-21 08:51:59 +01:00
|
|
|
mm.addTemplate(m, t)
|
|
|
|
mm.save(m)
|
|
|
|
# create a new note; it should have 3 cards
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "1"
|
|
|
|
note["Back"] = "1"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
assert col.cardCount() == 3
|
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# ordinals should arrive in order
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.getCard().ord == 0
|
|
|
|
assert col.sched.getCard().ord == 1
|
|
|
|
assert col.sched.getCard().ord == 2
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_counts_idx():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (1, 0, 0)
|
|
|
|
c = col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
# counter's been decremented but idx indicates 1
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.counts() == (0, 0, 0)
|
|
|
|
assert col.sched.countIdx(c) == 0
|
2012-12-21 08:51:59 +01:00
|
|
|
# answer to move to learn queue
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
# fetching again will decrement the count
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
|
|
|
assert col.sched.counts() == (0, 0, 0)
|
|
|
|
assert col.sched.countIdx(c) == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
# answering should add it back again
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_repCounts():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# lrnReps should be accurate on pass/fail
|
2020-07-17 05:21:12 +02:00
|
|
|
assert col.sched.counts() == (1, 0, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 1)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 1)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 3)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 1)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 3)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 3)
|
|
|
|
assert col.sched.counts() == (0, 0, 0)
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# initial pass should be correct too
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(col.sched.getCard(), 3)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 1)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 4)
|
|
|
|
assert col.sched.counts() == (0, 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
# immediate graduate should work
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "three"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 4)
|
|
|
|
assert col.sched.counts() == (0, 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
# and failing a review should too
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "three"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
|
|
|
c.queue = QUEUE_TYPE_REV
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today
|
2012-12-21 08:51:59 +01:00
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (0, 0, 1)
|
|
|
|
col.sched.answerCard(col.sched.getCard(), 1)
|
|
|
|
assert col.sched.counts() == (0, 1, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_timing():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a few review cards, due today
|
|
|
|
for i in range(5):
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "num" + str(i)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
|
|
|
c.queue = QUEUE_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
c.due = 0
|
|
|
|
c.flush()
|
|
|
|
# fail the first one
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 08:51:59 +01:00
|
|
|
# the next card should be another review
|
2020-07-17 05:21:12 +02:00
|
|
|
c2 = col.sched.getCard()
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c2.queue == QUEUE_TYPE_REV
|
2017-12-24 10:27:19 +01:00
|
|
|
# if the failed card becomes due, it should show first
|
2020-03-26 10:05:18 +01:00
|
|
|
c.due = intTime() - 1
|
2017-12-24 10:27:19 +01:00
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
2020-02-02 10:28:04 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_LRN
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_collapse():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
2012-12-21 08:51:59 +01:00
|
|
|
# test collapsing
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 4)
|
|
|
|
assert not col.sched.getCard()
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_deckDue():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note with default deck
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# and one that's a child
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
default1 = note.model()["did"] = col.decks.id("Default::1")
|
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# make it a review card
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = QUEUE_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
c.due = 0
|
|
|
|
c.flush()
|
|
|
|
# add one more with a new deck
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "two"
|
2020-07-20 10:16:39 +02:00
|
|
|
note.model()["did"] = col.decks.id("foo::bar")
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# and one that's a sibling
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "three"
|
2020-07-20 10:16:39 +02:00
|
|
|
note.model()["did"] = col.decks.id("foo::baz")
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
col.reset()
|
|
|
|
assert len(col.decks.all_names_and_ids()) == 5
|
|
|
|
tree = col.sched.deck_due_tree().children
|
2020-05-16 04:10:40 +02:00
|
|
|
assert tree[0].name == "Default"
|
2012-12-21 08:51:59 +01:00
|
|
|
# sum of child and parent
|
2020-05-16 04:10:40 +02:00
|
|
|
assert tree[0].deck_id == 1
|
|
|
|
assert tree[0].review_count == 1
|
|
|
|
assert tree[0].new_count == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
# child count is just review
|
2020-05-16 04:10:40 +02:00
|
|
|
child = tree[0].children[0]
|
|
|
|
assert child.name == "1"
|
|
|
|
assert child.deck_id == default1
|
|
|
|
assert child.review_count == 1
|
|
|
|
assert child.new_count == 0
|
2012-12-21 08:51:59 +01:00
|
|
|
# code should not fail if a card has an invalid deck
|
2019-12-25 05:18:34 +01:00
|
|
|
c.did = 12345
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.deck_due_tree()
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_deckTree():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
col.decks.id("new::b::c")
|
|
|
|
col.decks.id("new2")
|
2012-12-21 08:51:59 +01:00
|
|
|
# new should not appear twice in tree
|
2020-07-17 05:21:12 +02:00
|
|
|
names = [x.name for x in col.sched.deck_due_tree().children]
|
2012-12-21 08:51:59 +01:00
|
|
|
names.remove("new")
|
|
|
|
assert "new" not in names
|
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_deckFlow():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note with default deck
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# and one that's a child
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "two"
|
2020-07-20 10:16:39 +02:00
|
|
|
note.model()["did"] = col.decks.id("Default::2")
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# and another that's higher up
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "three"
|
2020-07-17 05:21:12 +02:00
|
|
|
default1 = note.model()["did"] = col.decks.id("Default::1")
|
|
|
|
col.addNote(note)
|
2012-12-21 08:51:59 +01:00
|
|
|
# should get top level one first, then ::1, then ::2
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (3, 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
for i in "one", "three", "two":
|
2020-07-17 05:21:12 +02:00
|
|
|
c = col.sched.getCard()
|
2019-12-25 05:18:34 +01:00
|
|
|
assert c.note()["Front"] == i
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 3)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_reorder():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note with default deck
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
|
|
|
note2 = col.newNote()
|
2020-07-17 05:18:35 +02:00
|
|
|
note2["Front"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note2)
|
2020-07-17 05:18:35 +02:00
|
|
|
assert note2.cards()[0].due == 2
|
2019-12-25 05:18:34 +01:00
|
|
|
found = False
|
2012-12-21 08:51:59 +01:00
|
|
|
# 50/50 chance of being reordered
|
|
|
|
for i in range(20):
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.randomizeCards(1)
|
2020-07-17 05:18:09 +02:00
|
|
|
if note.cards()[0].due != note.id:
|
2019-12-25 05:18:34 +01:00
|
|
|
found = True
|
2012-12-21 08:51:59 +01:00
|
|
|
break
|
|
|
|
assert found
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.orderCards(1)
|
2020-07-17 05:18:09 +02:00
|
|
|
assert note.cards()[0].due == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
# shifting
|
2020-07-17 17:33:58 +02:00
|
|
|
note3 = col.newNote()
|
|
|
|
note3["Front"] = "three"
|
|
|
|
col.addNote(note3)
|
2020-07-17 17:34:39 +02:00
|
|
|
note4 = col.newNote()
|
|
|
|
note4["Front"] = "four"
|
|
|
|
col.addNote(note4)
|
2020-07-17 05:18:09 +02:00
|
|
|
assert note.cards()[0].due == 1
|
2020-07-17 05:18:35 +02:00
|
|
|
assert note2.cards()[0].due == 2
|
2020-07-17 17:33:58 +02:00
|
|
|
assert note3.cards()[0].due == 3
|
2020-07-17 17:34:39 +02:00
|
|
|
assert note4.cards()[0].due == 4
|
|
|
|
col.sched.sortCards([note3.cards()[0].id, note4.cards()[0].id], start=1, shift=True)
|
2020-07-17 05:18:09 +02:00
|
|
|
assert note.cards()[0].due == 3
|
2020-07-17 05:18:35 +02:00
|
|
|
assert note2.cards()[0].due == 4
|
2020-07-17 17:33:58 +02:00
|
|
|
assert note3.cards()[0].due == 1
|
2020-07-17 17:34:39 +02:00
|
|
|
assert note4.cards()[0].due == 2
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_forget():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = QUEUE_TYPE_REV
|
|
|
|
c.type = CARD_TYPE_REV
|
2019-12-25 05:18:34 +01:00
|
|
|
c.ivl = 100
|
|
|
|
c.due = 0
|
2012-12-21 08:51:59 +01:00
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (0, 0, 1)
|
|
|
|
col.sched.forgetCards([c.id])
|
|
|
|
col.reset()
|
|
|
|
assert col.sched.counts() == (1, 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_resched():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.reschedCards([c.id], 0, 0)
|
2012-12-21 08:51:59 +01:00
|
|
|
c.load()
|
2020-07-17 05:21:12 +02:00
|
|
|
assert c.due == col.sched.today
|
2012-12-21 08:51:59 +01:00
|
|
|
assert c.ivl == 1
|
2020-02-02 10:40:30 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_REV and c.type == CARD_TYPE_REV
|
2021-02-08 13:33:27 +01:00
|
|
|
# make it due tomorrow
|
Rework reschedule tool
The old rescheduling dialog's two options have been split into two
separate menu items, "Forget", and "Set Due Date"
For cards that are not review cards, "Set Due Date" behaves like the
old reschedule option, changing the cards into a review card, and
and setting both the interval and due date to the provided number of
days.
When "Set Due Date" is applied to a review card, it no longer resets
the card's interval. Instead, it looks at how much the provided number
of days will change the original interval, and adjusts the interval by
that amount, so that cards that are answered earlier receive a smaller
next interval, and cards that are answered after a longer delay receive
a bonus.
For example, imagine a card was answered on day 5, and given an interval
of 10 days, so it has a due date of day 15.
- if on day 10 the due date is changed to day 12 (today+2), the card
is being scheduled 3 days earlier than it was supposed to be, so the
interval will be adjusted to 7 days.
- and if on day 10 the due date is changed to day 20, the interval will
be changed from 10 days to 15 days.
There is no separate option to reset the interval of a review card, but
it can be accomplished by forgetting the card(s), and then setting the
desired due date.
Other notes:
- Added the action to the review screen as well.
- Set the shortcut to Ctrl+Shift+D, and changed the existing Delete
Tags shortcut to Ctrl+Alt+Shift+A.
2021-02-07 11:58:16 +01:00
|
|
|
col.sched.reschedCards([c.id], 1, 1)
|
|
|
|
c.load()
|
|
|
|
assert c.due == col.sched.today + 1
|
|
|
|
assert c.ivl == 1
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
def test_norelearn():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2012-12-21 08:51:59 +01:00
|
|
|
# add a note
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
|
|
|
c.queue = QUEUE_TYPE_REV
|
2012-12-21 08:51:59 +01:00
|
|
|
c.due = 0
|
2017-02-08 08:28:05 +01:00
|
|
|
c.factor = STARTING_FACTOR
|
2012-12-21 08:51:59 +01:00
|
|
|
c.reps = 3
|
|
|
|
c.lapses = 1
|
|
|
|
c.ivl = 100
|
|
|
|
c.startTimer()
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
col.sched.answerCard(c, 1)
|
|
|
|
col.sched._cardConf(c)["lapse"]["delays"] = []
|
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 23:32:49 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2012-12-21 23:32:49 +01:00
|
|
|
def test_failmult():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2020-02-02 10:40:30 +01:00
|
|
|
c.type = CARD_TYPE_REV
|
|
|
|
c.queue = QUEUE_TYPE_REV
|
2012-12-21 23:32:49 +01:00
|
|
|
c.ivl = 100
|
2020-07-17 05:21:12 +02:00
|
|
|
c.due = col.sched.today - c.ivl
|
2017-02-08 08:28:05 +01:00
|
|
|
c.factor = STARTING_FACTOR
|
2012-12-21 23:32:49 +01:00
|
|
|
c.reps = 3
|
|
|
|
c.lapses = 1
|
|
|
|
c.startTimer()
|
|
|
|
c.flush()
|
2020-07-17 05:21:12 +02:00
|
|
|
conf = col.sched._cardConf(c)
|
2020-03-30 04:27:52 +02:00
|
|
|
conf["lapse"]["mult"] = 0.5
|
2020-07-17 05:21:12 +02:00
|
|
|
col.decks.save(conf)
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
2012-12-21 23:32:49 +01:00
|
|
|
assert c.ivl == 50
|
2020-07-17 05:21:12 +02:00
|
|
|
col.sched.answerCard(c, 1)
|
2018-07-27 06:59:45 +02:00
|
|
|
assert c.ivl == 25
|
2018-01-14 07:58:12 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2018-01-14 07:58:12 +01:00
|
|
|
def test_moveVersions():
|
2019-12-06 09:37:39 +01:00
|
|
|
col = getEmptyCol()
|
|
|
|
col.changeSchedulerVer(1)
|
2018-01-14 07:58:12 +01:00
|
|
|
|
|
|
|
n = col.newNote()
|
2019-12-25 05:18:34 +01:00
|
|
|
n["Front"] = "one"
|
2018-01-14 07:58:12 +01:00
|
|
|
col.addNote(n)
|
|
|
|
|
|
|
|
# make it a learning card
|
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
|
|
|
|
|
|
|
# the move to v2 should reset it to new
|
|
|
|
col.changeSchedulerVer(2)
|
|
|
|
c.load()
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_NEW
|
|
|
|
assert c.type == CARD_TYPE_NEW
|
2018-01-14 07:58:12 +01:00
|
|
|
|
|
|
|
# fail it again, and manually bury it
|
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
2020-08-31 08:14:04 +02:00
|
|
|
col.sched.bury_cards([c.id])
|
2018-01-14 07:58:12 +01:00
|
|
|
c.load()
|
2020-01-31 04:21:20 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_MANUALLY_BURIED
|
2018-01-14 07:58:12 +01:00
|
|
|
|
|
|
|
# revert to version 1
|
|
|
|
col.changeSchedulerVer(1)
|
|
|
|
|
|
|
|
# card should have moved queues
|
|
|
|
c.load()
|
2020-01-31 04:40:51 +01:00
|
|
|
assert c.queue == QUEUE_TYPE_SIBLING_BURIED
|
2018-01-14 07:58:12 +01:00
|
|
|
|
|
|
|
# and it should be new again when unburied
|
2020-08-29 14:02:22 +02:00
|
|
|
col.sched.unbury_cards_in_current_deck()
|
2018-01-14 07:58:12 +01:00
|
|
|
c.load()
|
2020-02-02 10:19:45 +01:00
|
|
|
assert c.type == CARD_TYPE_NEW and c.queue == QUEUE_TYPE_NEW
|
2019-06-14 01:15:38 +02:00
|
|
|
|
|
|
|
# make sure relearning cards transition correctly to v1
|
|
|
|
col.changeSchedulerVer(2)
|
|
|
|
# card with 100 day interval, answering again
|
|
|
|
col.sched.reschedCards([c.id], 100, 100)
|
2019-12-25 05:18:34 +01:00
|
|
|
c.load()
|
|
|
|
c.due = 0
|
|
|
|
c.flush()
|
2020-03-30 04:27:52 +02:00
|
|
|
conf = col.sched._cardConf(c)
|
|
|
|
conf["lapse"]["mult"] = 0.5
|
|
|
|
col.decks.save(conf)
|
2019-06-14 01:15:38 +02:00
|
|
|
col.sched.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 1)
|
|
|
|
# due should be correctly set when removed from learning early
|
|
|
|
col.changeSchedulerVer(1)
|
|
|
|
c.load()
|
|
|
|
assert c.due == 50
|
2019-09-24 07:38:33 +02:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
|
2019-09-24 07:38:33 +02:00
|
|
|
# cards with a due date earlier than the collection should retain
|
|
|
|
# their due date when removed
|
|
|
|
def test_negativeDueFilter():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
2019-09-24 07:38:33 +02:00
|
|
|
|
|
|
|
# card due prior to collection date
|
2020-07-17 05:21:12 +02:00
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-07-17 05:18:09 +02:00
|
|
|
c = note.cards()[0]
|
2019-09-24 07:38:33 +02:00
|
|
|
c.due = -5
|
2020-02-02 10:40:30 +01:00
|
|
|
c.queue = QUEUE_TYPE_REV
|
2019-09-24 07:38:33 +02:00
|
|
|
c.ivl = 5
|
|
|
|
c.flush()
|
|
|
|
|
|
|
|
# into and out of filtered deck
|
2020-09-03 10:02:47 +02:00
|
|
|
did = col.decks.new_filtered("Cram")
|
|
|
|
col.sched.rebuild_filtered_deck(did)
|
2020-09-03 09:43:07 +02:00
|
|
|
col.sched.empty_filtered_deck(did)
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
2019-09-24 07:38:33 +02:00
|
|
|
|
|
|
|
c.load()
|
|
|
|
assert c.due == -5
|
2020-01-19 06:41:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
# hard on the first step should be the average of again and good,
|
|
|
|
# and it should be logged properly
|
|
|
|
def test_initial_repeat():
|
2020-07-17 05:21:12 +02:00
|
|
|
col = getEmptyCol()
|
|
|
|
note = col.newNote()
|
2020-07-17 05:18:09 +02:00
|
|
|
note["Front"] = "one"
|
|
|
|
note["Back"] = "two"
|
2020-07-17 05:21:12 +02:00
|
|
|
col.addNote(note)
|
2020-01-19 06:41:58 +01:00
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
col.reset()
|
|
|
|
c = col.sched.getCard()
|
|
|
|
col.sched.answerCard(c, 2)
|
2020-01-19 06:41:58 +01:00
|
|
|
# should be due in ~ 5.5 mins
|
|
|
|
expected = time.time() + 5.5 * 60
|
|
|
|
assert expected - 10 < c.due < expected * 1.25
|
|
|
|
|
2020-07-17 05:21:12 +02:00
|
|
|
ivl = col.db.scalar("select ivl from revlog")
|
2020-01-19 06:41:58 +01:00
|
|
|
assert ivl == -5.5 * 60
|