mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
update tests
This commit is contained in:
parent
cf6d85baa4
commit
ea82126fcb
5 changed files with 1165 additions and 5 deletions
|
@ -12,7 +12,7 @@ def assertException(exception, func):
|
||||||
|
|
||||||
# Creating new decks is expensive. Just do it once, and then spin off
|
# Creating new decks is expensive. Just do it once, and then spin off
|
||||||
# copies from the master.
|
# copies from the master.
|
||||||
def getEmptyCol():
|
def getEmptyCol(schedVer=1):
|
||||||
if len(getEmptyCol.master) == 0:
|
if len(getEmptyCol.master) == 0:
|
||||||
(fd, nam) = tempfile.mkstemp(suffix=".anki2")
|
(fd, nam) = tempfile.mkstemp(suffix=".anki2")
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
@ -22,7 +22,11 @@ def getEmptyCol():
|
||||||
getEmptyCol.master = nam
|
getEmptyCol.master = nam
|
||||||
(fd, nam) = tempfile.mkstemp(suffix=".anki2")
|
(fd, nam) = tempfile.mkstemp(suffix=".anki2")
|
||||||
shutil.copy(getEmptyCol.master, nam)
|
shutil.copy(getEmptyCol.master, nam)
|
||||||
return aopen(nam)
|
from anki.collection import _Collection
|
||||||
|
_Collection.defaultSchedulerVersion = schedVer
|
||||||
|
col = aopen(nam)
|
||||||
|
_Collection.defaultSchedulerVersion = 1
|
||||||
|
return col
|
||||||
|
|
||||||
getEmptyCol.master = ""
|
getEmptyCol.master = ""
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ def test_export_ankipkg():
|
||||||
|
|
||||||
@nose.with_setup(setup1)
|
@nose.with_setup(setup1)
|
||||||
def test_export_anki_due():
|
def test_export_anki_due():
|
||||||
deck = getEmptyCol()
|
deck = getEmptyCol(schedVer=2)
|
||||||
f = deck.newNote()
|
f = deck.newNote()
|
||||||
f['Front'] = "foo"
|
f['Front'] = "foo"
|
||||||
deck.addNote(f)
|
deck.addNote(f)
|
||||||
|
|
1115
tests/test_schedv1.py
Normal file
1115
tests/test_schedv1.py
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,10 +4,13 @@ import time
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from anki.consts import STARTING_FACTOR
|
from anki.consts import STARTING_FACTOR
|
||||||
from tests.shared import getEmptyCol
|
from tests.shared import getEmptyCol as _getEmptyCol
|
||||||
from anki.utils import intTime
|
from anki.utils import intTime
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
|
|
||||||
|
def getEmptyCol():
|
||||||
|
return _getEmptyCol(schedVer=2)
|
||||||
|
|
||||||
def test_clock():
|
def test_clock():
|
||||||
d = getEmptyCol()
|
d = getEmptyCol()
|
||||||
if (d.sched.dayCutoff - intTime()) < 10*60:
|
if (d.sched.dayCutoff - intTime()) < 10*60:
|
||||||
|
@ -1082,3 +1085,41 @@ def test_failmult():
|
||||||
# so the card is reset to new
|
# so the card is reset to new
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
|
|
||||||
|
def test_moveVersions():
|
||||||
|
col = _getEmptyCol(schedVer=1)
|
||||||
|
|
||||||
|
n = col.newNote()
|
||||||
|
n['Front'] = "one"
|
||||||
|
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()
|
||||||
|
assert c.queue == 0
|
||||||
|
assert c.type == 0
|
||||||
|
|
||||||
|
# fail it again, and manually bury it
|
||||||
|
col.reset()
|
||||||
|
c = col.sched.getCard()
|
||||||
|
col.sched.answerCard(c, 1)
|
||||||
|
col.sched.buryCards([c.id])
|
||||||
|
c.load()
|
||||||
|
assert c.queue == -3
|
||||||
|
|
||||||
|
# revert to version 1
|
||||||
|
col.changeSchedulerVer(1)
|
||||||
|
|
||||||
|
# card should have moved queues
|
||||||
|
c.load()
|
||||||
|
assert c.queue == -2
|
||||||
|
|
||||||
|
# and it should be new again when unburied
|
||||||
|
col.sched.unburyCards()
|
||||||
|
c.load()
|
||||||
|
assert c.queue == c.type == 0
|
|
@ -36,7 +36,7 @@ def test_op():
|
||||||
assert d.undoName() == "Review"
|
assert d.undoName() == "Review"
|
||||||
|
|
||||||
def test_review():
|
def test_review():
|
||||||
d = getEmptyCol()
|
d = getEmptyCol(schedVer=2)
|
||||||
d.conf['counts'] = COUNT_REMAINING
|
d.conf['counts'] = COUNT_REMAINING
|
||||||
f = d.newNote()
|
f = d.newNote()
|
||||||
f['Front'] = "one"
|
f['Front'] = "one"
|
||||||
|
|
Loading…
Reference in a new issue