f->note in test
Obtained by sed -i "s/\bf\b/note/g" pylib/tests/*py qt/tests/*py
This commit is contained in:
parent
6a529e51cc
commit
4c25835d27
@ -5,11 +5,11 @@ from tests.shared import getEmptyCol
|
||||
|
||||
def test_delete():
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = "2"
|
||||
deck.addNote(f)
|
||||
cid = f.cards()[0].id
|
||||
note = deck.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = "2"
|
||||
deck.addNote(note)
|
||||
cid = note.cards()[0].id
|
||||
deck.reset()
|
||||
deck.sched.answerCard(deck.sched.getCard(), 2)
|
||||
deck.remove_cards_and_orphaned_notes([cid])
|
||||
@ -22,22 +22,22 @@ def test_delete():
|
||||
|
||||
def test_misc():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = "2"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = "2"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
id = d.models.current()["id"]
|
||||
assert c.template()["ord"] == 0
|
||||
|
||||
|
||||
def test_genrem():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = ""
|
||||
d.addNote(f)
|
||||
assert len(f.cards()) == 1
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = ""
|
||||
d.addNote(note)
|
||||
assert len(note.cards()) == 1
|
||||
m = d.models.current()
|
||||
mm = d.models
|
||||
# adding a new template should automatically create cards
|
||||
@ -46,7 +46,7 @@ def test_genrem():
|
||||
t["afmt"] = ""
|
||||
mm.addTemplate(m, t)
|
||||
mm.save(m, templates=True)
|
||||
assert len(f.cards()) == 2
|
||||
assert len(note.cards()) == 2
|
||||
# if the template is changed to remove cards, they'll be removed
|
||||
t = m["tmpls"][1]
|
||||
t["qfmt"] = "{{Back}}"
|
||||
@ -54,40 +54,40 @@ def test_genrem():
|
||||
rep = d.backend.get_empty_cards()
|
||||
for n in rep.notes:
|
||||
d.remove_cards_and_orphaned_notes(n.card_ids)
|
||||
assert len(f.cards()) == 1
|
||||
assert len(note.cards()) == 1
|
||||
# if we add to the note, a card should be automatically generated
|
||||
f.load()
|
||||
f["Back"] = "1"
|
||||
f.flush()
|
||||
assert len(f.cards()) == 2
|
||||
note.load()
|
||||
note["Back"] = "1"
|
||||
note.flush()
|
||||
assert len(note.cards()) == 2
|
||||
|
||||
|
||||
def test_gendeck():
|
||||
d = getEmptyCol()
|
||||
cloze = d.models.byName("Cloze")
|
||||
d.models.setCurrent(cloze)
|
||||
f = d.newNote()
|
||||
f["Text"] = "{{c1::one}}"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Text"] = "{{c1::one}}"
|
||||
d.addNote(note)
|
||||
assert d.cardCount() == 1
|
||||
assert f.cards()[0].did == 1
|
||||
assert note.cards()[0].did == 1
|
||||
# set the model to a new default deck
|
||||
newId = d.decks.id("new")
|
||||
cloze["did"] = newId
|
||||
d.models.save(cloze, updateReqs=False)
|
||||
# a newly generated card should share the first card's deck
|
||||
f["Text"] += "{{c2::two}}"
|
||||
f.flush()
|
||||
assert f.cards()[1].did == 1
|
||||
note["Text"] += "{{c2::two}}"
|
||||
note.flush()
|
||||
assert note.cards()[1].did == 1
|
||||
# and same with multiple cards
|
||||
f["Text"] += "{{c3::three}}"
|
||||
f.flush()
|
||||
assert f.cards()[2].did == 1
|
||||
note["Text"] += "{{c3::three}}"
|
||||
note.flush()
|
||||
assert note.cards()[2].did == 1
|
||||
# if one of the cards is in a different deck, it should revert to the
|
||||
# model default
|
||||
c = f.cards()[1]
|
||||
c = note.cards()[1]
|
||||
c.did = newId
|
||||
c.flush()
|
||||
f["Text"] += "{{c4::four}}"
|
||||
f.flush()
|
||||
assert f.cards()[3].did == newId
|
||||
note["Text"] += "{{c4::four}}"
|
||||
note.flush()
|
||||
assert note.cards()[3].did == newId
|
||||
|
@ -47,10 +47,10 @@ def test_create_open():
|
||||
def test_noteAddDelete():
|
||||
deck = getEmptyCol()
|
||||
# add a note
|
||||
f = deck.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
n = deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
n = deck.addNote(note)
|
||||
assert n == 1
|
||||
# test multiple cards - add another template
|
||||
m = deck.models.current()
|
||||
@ -62,17 +62,17 @@ def test_noteAddDelete():
|
||||
mm.save(m)
|
||||
assert deck.cardCount() == 2
|
||||
# creating new notes should use both cards
|
||||
f = deck.newNote()
|
||||
f["Front"] = "three"
|
||||
f["Back"] = "four"
|
||||
n = deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "three"
|
||||
note["Back"] = "four"
|
||||
n = deck.addNote(note)
|
||||
assert n == 2
|
||||
assert deck.cardCount() == 4
|
||||
# check q/a generation
|
||||
c0 = f.cards()[0]
|
||||
c0 = note.cards()[0]
|
||||
assert "three" in c0.q()
|
||||
# it should not be a duplicate
|
||||
assert not f.dupeOrEmpty()
|
||||
assert not note.dupeOrEmpty()
|
||||
# now let's make a duplicate
|
||||
f2 = deck.newNote()
|
||||
f2["Front"] = "one"
|
||||
@ -85,36 +85,36 @@ def test_noteAddDelete():
|
||||
|
||||
def test_fieldChecksum():
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "new"
|
||||
f["Back"] = "new2"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "new"
|
||||
note["Back"] = "new2"
|
||||
deck.addNote(note)
|
||||
assert deck.db.scalar("select csum from notes") == int("c2a6b03f", 16)
|
||||
# changing the val should change the checksum
|
||||
f["Front"] = "newx"
|
||||
f.flush()
|
||||
note["Front"] = "newx"
|
||||
note.flush()
|
||||
assert deck.db.scalar("select csum from notes") == int("302811ae", 16)
|
||||
|
||||
|
||||
def test_addDelTags():
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "1"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "1"
|
||||
deck.addNote(note)
|
||||
f2 = deck.newNote()
|
||||
f2["Front"] = "2"
|
||||
deck.addNote(f2)
|
||||
# adding for a given id
|
||||
deck.tags.bulkAdd([f.id], "foo")
|
||||
f.load()
|
||||
deck.tags.bulkAdd([note.id], "foo")
|
||||
note.load()
|
||||
f2.load()
|
||||
assert "foo" in f.tags
|
||||
assert "foo" in note.tags
|
||||
assert "foo" not in f2.tags
|
||||
# should be canonified
|
||||
deck.tags.bulkAdd([f.id], "foo aaa")
|
||||
f.load()
|
||||
assert f.tags[0] == "aaa"
|
||||
assert len(f.tags) == 2
|
||||
deck.tags.bulkAdd([note.id], "foo aaa")
|
||||
note.load()
|
||||
assert note.tags[0] == "aaa"
|
||||
assert len(note.tags) == 2
|
||||
|
||||
|
||||
def test_timestamps():
|
||||
|
@ -47,11 +47,11 @@ def test_remove():
|
||||
deck = getEmptyCol()
|
||||
# create a new deck, and add a note/card to it
|
||||
g1 = deck.decks.id("g1")
|
||||
f = deck.newNote()
|
||||
f["Front"] = "1"
|
||||
f.model()["did"] = g1
|
||||
deck.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = deck.newNote()
|
||||
note["Front"] = "1"
|
||||
note.model()["did"] = g1
|
||||
deck.addNote(note)
|
||||
c = note.cards()[0]
|
||||
assert c.did == g1
|
||||
assert deck.cardCount() == 1
|
||||
deck.decks.rem(g1)
|
||||
|
@ -24,17 +24,17 @@ testDir = os.path.dirname(__file__)
|
||||
def setup1():
|
||||
global deck
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "foo"
|
||||
f["Back"] = "bar<br>"
|
||||
f.tags = ["tag", "tag2"]
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "foo"
|
||||
note["Back"] = "bar<br>"
|
||||
note.tags = ["tag", "tag2"]
|
||||
deck.addNote(note)
|
||||
# with a different deck
|
||||
f = deck.newNote()
|
||||
f["Front"] = "baz"
|
||||
f["Back"] = "qux"
|
||||
f.model()["did"] = deck.decks.id("new deck")
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "baz"
|
||||
note["Back"] = "qux"
|
||||
note.model()["did"] = deck.decks.id("new deck")
|
||||
deck.addNote(note)
|
||||
|
||||
|
||||
##########################################################################
|
||||
@ -85,8 +85,8 @@ def test_export_anki():
|
||||
def test_export_ankipkg():
|
||||
setup1()
|
||||
# add a test file to the media folder
|
||||
with open(os.path.join(deck.media.dir(), "今日.mp3"), "w") as f:
|
||||
f.write("test")
|
||||
with open(os.path.join(deck.media.dir(), "今日.mp3"), "w") as note:
|
||||
note.write("test")
|
||||
n = deck.newNote()
|
||||
n["Front"] = "[sound:今日.mp3]"
|
||||
deck.addNote(n)
|
||||
@ -102,9 +102,9 @@ def test_export_ankipkg():
|
||||
def test_export_anki_due():
|
||||
setup1()
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "foo"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "foo"
|
||||
deck.addNote(note)
|
||||
deck.crt -= 86400 * 10
|
||||
deck.flush()
|
||||
deck.sched.reset()
|
||||
@ -136,27 +136,27 @@ def test_export_anki_due():
|
||||
# def test_export_textcard():
|
||||
# setup1()
|
||||
# e = TextCardExporter(deck)
|
||||
# f = unicode(tempfile.mkstemp(prefix="ankitest")[1])
|
||||
# os.unlink(f)
|
||||
# e.exportInto(f)
|
||||
# note = unicode(tempfile.mkstemp(prefix="ankitest")[1])
|
||||
# os.unlink(note)
|
||||
# e.exportInto(note)
|
||||
# e.includeTags = True
|
||||
# e.exportInto(f)
|
||||
# e.exportInto(note)
|
||||
|
||||
|
||||
def test_export_textnote():
|
||||
setup1()
|
||||
e = TextNoteExporter(deck)
|
||||
fd, f = tempfile.mkstemp(prefix="ankitest")
|
||||
f = str(f)
|
||||
fd, note = tempfile.mkstemp(prefix="ankitest")
|
||||
note = str(note)
|
||||
os.close(fd)
|
||||
os.unlink(f)
|
||||
e.exportInto(f)
|
||||
with open(f) as file:
|
||||
os.unlink(note)
|
||||
e.exportInto(note)
|
||||
with open(note) as file:
|
||||
assert file.readline() == "foo\tbar<br>\ttag tag2\n"
|
||||
e.includeTags = False
|
||||
e.includeHTML = False
|
||||
e.exportInto(f)
|
||||
with open(f) as file:
|
||||
e.exportInto(note)
|
||||
with open(note) as file:
|
||||
assert file.readline() == "foo\tbar\n"
|
||||
|
||||
|
||||
|
@ -13,24 +13,24 @@ class DummyCollection:
|
||||
|
||||
def test_findCards():
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "dog"
|
||||
f["Back"] = "cat"
|
||||
f.tags.append("monkey animal_1 * %")
|
||||
deck.addNote(f)
|
||||
f1id = f.id
|
||||
firstCardId = f.cards()[0].id
|
||||
f = deck.newNote()
|
||||
f["Front"] = "goats are fun"
|
||||
f["Back"] = "sheep"
|
||||
f.tags.append("sheep goat horse animal11")
|
||||
deck.addNote(f)
|
||||
f2id = f.id
|
||||
f = deck.newNote()
|
||||
f["Front"] = "cat"
|
||||
f["Back"] = "sheep"
|
||||
deck.addNote(f)
|
||||
catCard = f.cards()[0]
|
||||
note = deck.newNote()
|
||||
note["Front"] = "dog"
|
||||
note["Back"] = "cat"
|
||||
note.tags.append("monkey animal_1 * %")
|
||||
deck.addNote(note)
|
||||
f1id = note.id
|
||||
firstCardId = note.cards()[0].id
|
||||
note = deck.newNote()
|
||||
note["Front"] = "goats are fun"
|
||||
note["Back"] = "sheep"
|
||||
note.tags.append("sheep goat horse animal11")
|
||||
deck.addNote(note)
|
||||
f2id = note.id
|
||||
note = deck.newNote()
|
||||
note["Front"] = "cat"
|
||||
note["Back"] = "sheep"
|
||||
deck.addNote(note)
|
||||
catCard = note.cards()[0]
|
||||
m = deck.models.current()
|
||||
m = deck.models.copy(m)
|
||||
mm = deck.models
|
||||
@ -39,12 +39,12 @@ def test_findCards():
|
||||
t["afmt"] = "{{Front}}"
|
||||
mm.addTemplate(m, t)
|
||||
mm.save(m)
|
||||
f = deck.newNote()
|
||||
f["Front"] = "test"
|
||||
f["Back"] = "foo bar"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "test"
|
||||
note["Back"] = "foo bar"
|
||||
deck.addNote(note)
|
||||
deck.save()
|
||||
latestCardIds = [c.id for c in f.cards()]
|
||||
latestCardIds = [c.id for c in note.cards()]
|
||||
# tag searches
|
||||
assert len(deck.findCards("tag:*")) == 5
|
||||
assert len(deck.findCards("tag:\\*")) == 1
|
||||
@ -72,7 +72,7 @@ def test_findCards():
|
||||
assert len(deck.findCards('"are goats"')) == 0
|
||||
assert len(deck.findCards('"goats are"')) == 1
|
||||
# card states
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.queue = c.type = CARD_TYPE_REV
|
||||
assert deck.findCards("is:review") == []
|
||||
c.flush()
|
||||
@ -90,7 +90,7 @@ def test_findCards():
|
||||
assert deck.findCards("is:suspended") == [c.id]
|
||||
# nids
|
||||
assert deck.findCards("nid:54321") == []
|
||||
assert len(deck.findCards("nid:%d" % f.id)) == 2
|
||||
assert len(deck.findCards("nid:%d" % note.id)) == 2
|
||||
assert len(deck.findCards("nid:%d,%d" % (f1id, f2id))) == 2
|
||||
# templates
|
||||
assert len(deck.findCards("card:foo")) == 0
|
||||
@ -142,16 +142,16 @@ def test_findCards():
|
||||
assert len(deck.findCards("deck:*EFAULT")) == 5
|
||||
assert len(deck.findCards("deck:*cefault")) == 0
|
||||
# full search
|
||||
f = deck.newNote()
|
||||
f["Front"] = "hello<b>world</b>"
|
||||
f["Back"] = "abc"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "hello<b>world</b>"
|
||||
note["Back"] = "abc"
|
||||
deck.addNote(note)
|
||||
# as it's the sort field, it matches
|
||||
assert len(deck.findCards("helloworld")) == 2
|
||||
# assert len(deck.findCards("helloworld", full=True)) == 2
|
||||
# if we put it on the back, it won't
|
||||
(f["Front"], f["Back"]) = (f["Back"], f["Front"])
|
||||
f.flush()
|
||||
(note["Front"], note["Back"]) = (note["Back"], note["Front"])
|
||||
note.flush()
|
||||
assert len(deck.findCards("helloworld")) == 0
|
||||
# assert len(deck.findCards("helloworld", full=True)) == 2
|
||||
# assert len(deck.findCards("back:helloworld", full=True)) == 2
|
||||
@ -213,10 +213,10 @@ def test_findCards():
|
||||
print("some find tests disabled near cutoff")
|
||||
# empty field
|
||||
assert len(deck.findCards("front:")) == 0
|
||||
f = deck.newNote()
|
||||
f["Front"] = ""
|
||||
f["Back"] = "abc2"
|
||||
assert deck.addNote(f) == 1
|
||||
note = deck.newNote()
|
||||
note["Front"] = ""
|
||||
note["Back"] = "abc2"
|
||||
assert deck.addNote(note) == 1
|
||||
assert len(deck.findCards("front:")) == 1
|
||||
# OR searches and nesting
|
||||
assert len(deck.findCards("tag:monkey or tag:sheep")) == 2
|
||||
@ -231,44 +231,44 @@ def test_findCards():
|
||||
|
||||
def test_findReplace():
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "foo"
|
||||
f["Back"] = "bar"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "foo"
|
||||
note["Back"] = "bar"
|
||||
deck.addNote(note)
|
||||
f2 = deck.newNote()
|
||||
f2["Front"] = "baz"
|
||||
f2["Back"] = "foo"
|
||||
deck.addNote(f2)
|
||||
nids = [f.id, f2.id]
|
||||
nids = [note.id, f2.id]
|
||||
# should do nothing
|
||||
assert deck.findReplace(nids, "abc", "123") == 0
|
||||
# global replace
|
||||
assert deck.findReplace(nids, "foo", "qux") == 2
|
||||
f.load()
|
||||
assert f["Front"] == "qux"
|
||||
note.load()
|
||||
assert note["Front"] == "qux"
|
||||
f2.load()
|
||||
assert f2["Back"] == "qux"
|
||||
# single field replace
|
||||
assert deck.findReplace(nids, "qux", "foo", field="Front") == 1
|
||||
f.load()
|
||||
assert f["Front"] == "foo"
|
||||
note.load()
|
||||
assert note["Front"] == "foo"
|
||||
f2.load()
|
||||
assert f2["Back"] == "qux"
|
||||
# regex replace
|
||||
assert deck.findReplace(nids, "B.r", "reg") == 0
|
||||
f.load()
|
||||
assert f["Back"] != "reg"
|
||||
note.load()
|
||||
assert note["Back"] != "reg"
|
||||
assert deck.findReplace(nids, "B.r", "reg", regex=True) == 1
|
||||
f.load()
|
||||
assert f["Back"] == "reg"
|
||||
note.load()
|
||||
assert note["Back"] == "reg"
|
||||
|
||||
|
||||
def test_findDupes():
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "foo"
|
||||
f["Back"] = "bar"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "foo"
|
||||
note["Back"] = "bar"
|
||||
deck.addNote(note)
|
||||
f2 = deck.newNote()
|
||||
f2["Front"] = "baz"
|
||||
f2["Back"] = "bar"
|
||||
|
@ -37,8 +37,8 @@ def test_anki2_mediadupes():
|
||||
mid = n.model()["id"]
|
||||
tmp.addNote(n)
|
||||
# add that sound to media folder
|
||||
with open(os.path.join(tmp.media.dir(), "foo.mp3"), "w") as f:
|
||||
f.write("foo")
|
||||
with open(os.path.join(tmp.media.dir(), "foo.mp3"), "w") as note:
|
||||
note.write("foo")
|
||||
tmp.close()
|
||||
# it should be imported correctly into an empty deck
|
||||
empty = getEmptyCol()
|
||||
@ -55,8 +55,8 @@ def test_anki2_mediadupes():
|
||||
# if the local file content is different, and import should trigger a
|
||||
# rename
|
||||
empty.remove_cards_and_orphaned_notes(empty.db.list("select id from cards"))
|
||||
with open(os.path.join(empty.media.dir(), "foo.mp3"), "w") as f:
|
||||
f.write("bar")
|
||||
with open(os.path.join(empty.media.dir(), "foo.mp3"), "w") as note:
|
||||
note.write("bar")
|
||||
imp = Anki2Importer(empty, tmp.path)
|
||||
imp.run()
|
||||
assert sorted(os.listdir(empty.media.dir())) == ["foo.mp3", "foo_%s.mp3" % mid]
|
||||
@ -65,8 +65,8 @@ def test_anki2_mediadupes():
|
||||
# if the localized media file already exists, we rewrite the note and
|
||||
# media
|
||||
empty.remove_cards_and_orphaned_notes(empty.db.list("select id from cards"))
|
||||
with open(os.path.join(empty.media.dir(), "foo.mp3"), "w") as f:
|
||||
f.write("bar")
|
||||
with open(os.path.join(empty.media.dir(), "foo.mp3"), "w") as note:
|
||||
note.write("bar")
|
||||
imp = Anki2Importer(empty, tmp.path)
|
||||
imp.run()
|
||||
assert sorted(os.listdir(empty.media.dir())) == ["foo.mp3", "foo_%s.mp3" % mid]
|
||||
@ -89,8 +89,8 @@ def test_apkg():
|
||||
assert os.listdir(tmp.media.dir()) == ["foo.wav"]
|
||||
# but if the local file has different data, it will rename
|
||||
tmp.remove_cards_and_orphaned_notes(tmp.db.list("select id from cards"))
|
||||
with open(os.path.join(tmp.media.dir(), "foo.wav"), "w") as f:
|
||||
f.write("xyz")
|
||||
with open(os.path.join(tmp.media.dir(), "foo.wav"), "w") as note:
|
||||
note.write("xyz")
|
||||
imp = AnkiPackageImporter(tmp, apkg)
|
||||
imp.run()
|
||||
assert len(os.listdir(tmp.media.dir())) == 2
|
||||
@ -185,8 +185,8 @@ def test_csv2():
|
||||
deck = getEmptyCol()
|
||||
mm = deck.models
|
||||
m = mm.current()
|
||||
f = mm.newField("Three")
|
||||
mm.addField(m, f)
|
||||
note = mm.newField("Three")
|
||||
mm.addField(m, note)
|
||||
mm.save(m)
|
||||
n = deck.newNote()
|
||||
n["Front"] = "1"
|
||||
@ -209,8 +209,8 @@ def test_tsv_tag_modified():
|
||||
deck = getEmptyCol()
|
||||
mm = deck.models
|
||||
m = mm.current()
|
||||
f = mm.newField("Top")
|
||||
mm.addField(m, f)
|
||||
note = mm.newField("Top")
|
||||
mm.addField(m, note)
|
||||
mm.save(m)
|
||||
n = deck.newNote()
|
||||
n["Front"] = "1"
|
||||
@ -245,8 +245,8 @@ def test_tsv_tag_multiple_tags():
|
||||
deck = getEmptyCol()
|
||||
mm = deck.models
|
||||
m = mm.current()
|
||||
f = mm.newField("Top")
|
||||
mm.addField(m, f)
|
||||
note = mm.newField("Top")
|
||||
mm.addField(m, note)
|
||||
mm.save(m)
|
||||
n = deck.newNote()
|
||||
n["Front"] = "1"
|
||||
@ -279,8 +279,8 @@ def test_csv_tag_only_if_modified():
|
||||
deck = getEmptyCol()
|
||||
mm = deck.models
|
||||
m = mm.current()
|
||||
f = mm.newField("Left")
|
||||
mm.addField(m, f)
|
||||
note = mm.newField("Left")
|
||||
mm.addField(m, note)
|
||||
mm.save(m)
|
||||
n = deck.newNote()
|
||||
n["Front"] = "1"
|
||||
|
@ -13,13 +13,13 @@ def test_latex():
|
||||
|
||||
anki.latex.pngCommands[0][0] = "nolatex"
|
||||
# add a note with latex
|
||||
f = d.newNote()
|
||||
f["Front"] = "[latex]hello[/latex]"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "[latex]hello[/latex]"
|
||||
d.addNote(note)
|
||||
# but since latex couldn't run, there's nothing there
|
||||
assert len(os.listdir(d.media.dir())) == 0
|
||||
# check the error message
|
||||
msg = f.cards()[0].q()
|
||||
msg = note.cards()[0].q()
|
||||
assert "executing nolatex" in msg
|
||||
assert "installed" in msg
|
||||
# check if we have latex installed, and abort test if we don't
|
||||
@ -31,26 +31,26 @@ def test_latex():
|
||||
# check media db should cause latex to be generated
|
||||
d.media.render_all_latex()
|
||||
assert len(os.listdir(d.media.dir())) == 1
|
||||
assert ".png" in f.cards()[0].q()
|
||||
assert ".png" in note.cards()[0].q()
|
||||
# adding new notes should cause generation on question display
|
||||
f = d.newNote()
|
||||
f["Front"] = "[latex]world[/latex]"
|
||||
d.addNote(f)
|
||||
f.cards()[0].q()
|
||||
note = d.newNote()
|
||||
note["Front"] = "[latex]world[/latex]"
|
||||
d.addNote(note)
|
||||
note.cards()[0].q()
|
||||
assert len(os.listdir(d.media.dir())) == 2
|
||||
# another note with the same media should reuse
|
||||
f = d.newNote()
|
||||
f["Front"] = " [latex]world[/latex]"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = " [latex]world[/latex]"
|
||||
d.addNote(note)
|
||||
assert len(os.listdir(d.media.dir())) == 2
|
||||
oldcard = f.cards()[0]
|
||||
oldcard = note.cards()[0]
|
||||
assert ".png" in oldcard.q()
|
||||
# if we turn off building, then previous cards should work, but cards with
|
||||
# missing media will show a broken image
|
||||
anki.latex.build = False
|
||||
f = d.newNote()
|
||||
f["Front"] = "[latex]foo[/latex]"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "[latex]foo[/latex]"
|
||||
d.addNote(note)
|
||||
assert len(os.listdir(d.media.dir())) == 2
|
||||
assert ".png" in oldcard.q()
|
||||
# turn it on again so other test don't suffer
|
||||
@ -88,8 +88,8 @@ def test_latex():
|
||||
|
||||
def _test_includes_bad_command(bad):
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "[latex]%s[/latex]" % bad
|
||||
d.addNote(f)
|
||||
q = f.cards()[0].q()
|
||||
note = d.newNote()
|
||||
note["Front"] = "[latex]%s[/latex]" % bad
|
||||
d.addNote(note)
|
||||
q = note.cards()[0].q()
|
||||
return ("'%s' is not allowed on cards" % bad in q, "Card content: %s" % q)
|
||||
|
@ -11,15 +11,15 @@ def test_add():
|
||||
d = getEmptyCol()
|
||||
dir = tempfile.mkdtemp(prefix="anki")
|
||||
path = os.path.join(dir, "foo.jpg")
|
||||
with open(path, "w") as f:
|
||||
f.write("hello")
|
||||
with open(path, "w") as note:
|
||||
note.write("hello")
|
||||
# new file, should preserve name
|
||||
assert d.media.addFile(path) == "foo.jpg"
|
||||
# adding the same file again should not create a duplicate
|
||||
assert d.media.addFile(path) == "foo.jpg"
|
||||
# but if it has a different sha1, it should
|
||||
with open(path, "w") as f:
|
||||
f.write("world")
|
||||
with open(path, "w") as note:
|
||||
note.write("world")
|
||||
assert d.media.addFile(path) == "foo-7c211433f02071597741e6ff5a8ea34789abbf43.jpg"
|
||||
|
||||
|
||||
@ -60,18 +60,18 @@ def test_deckIntegration():
|
||||
file = str(os.path.join(testDir, "support/fake.png"))
|
||||
d.media.addFile(file)
|
||||
# add a note which references it
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "<img src='fake.png'>"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "<img src='fake.png'>"
|
||||
d.addNote(note)
|
||||
# and one which references a non-existent file
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "<img src='fake2.png'>"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "<img src='fake2.png'>"
|
||||
d.addNote(note)
|
||||
# and add another file which isn't used
|
||||
with open(os.path.join(d.media.dir(), "foo.jpg"), "w") as f:
|
||||
f.write("test")
|
||||
with open(os.path.join(d.media.dir(), "foo.jpg"), "w") as note:
|
||||
note.write("test")
|
||||
# check media
|
||||
ret = d.media.check()
|
||||
assert ret.missing == ["fake2.png"]
|
||||
|
@ -9,10 +9,10 @@ from tests.shared import getEmptyCol
|
||||
|
||||
def test_modelDelete():
|
||||
deck = getEmptyCol()
|
||||
f = deck.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = "2"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = "2"
|
||||
deck.addNote(note)
|
||||
assert deck.cardCount() == 1
|
||||
deck.models.rem(deck.models.current())
|
||||
assert deck.cardCount() == 0
|
||||
@ -34,23 +34,23 @@ def test_modelCopy():
|
||||
|
||||
def test_fields():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = "2"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = "2"
|
||||
d.addNote(note)
|
||||
m = d.models.current()
|
||||
# make sure renaming a field updates the templates
|
||||
d.models.renameField(m, m["flds"][0], "NewFront")
|
||||
assert "{{NewFront}}" in m["tmpls"][0]["qfmt"]
|
||||
h = d.models.scmhash(m)
|
||||
# add a field
|
||||
f = d.models.newField("foo")
|
||||
d.models.addField(m, f)
|
||||
note = d.models.newField("foo")
|
||||
d.models.addField(m, note)
|
||||
assert d.getNote(d.models.nids(m)[0]).fields == ["1", "2", ""]
|
||||
assert d.models.scmhash(m) != h
|
||||
# rename it
|
||||
f = m["flds"][2]
|
||||
d.models.renameField(m, f, "bar")
|
||||
note = m["flds"][2]
|
||||
d.models.renameField(m, note, "bar")
|
||||
assert d.getNote(d.models.nids(m)[0])["bar"] == ""
|
||||
# delete back
|
||||
d.models.remField(m, m["flds"][1])
|
||||
@ -62,11 +62,11 @@ def test_fields():
|
||||
d.models.moveField(m, m["flds"][1], 0)
|
||||
assert d.getNote(d.models.nids(m)[0]).fields == ["1", ""]
|
||||
# add another and put in middle
|
||||
f = d.models.newField("baz")
|
||||
d.models.addField(m, f)
|
||||
f = d.getNote(d.models.nids(m)[0])
|
||||
f["baz"] = "2"
|
||||
f.flush()
|
||||
note = d.models.newField("baz")
|
||||
d.models.addField(m, note)
|
||||
note = d.getNote(d.models.nids(m)[0])
|
||||
note["baz"] = "2"
|
||||
note.flush()
|
||||
assert d.getNote(d.models.nids(m)[0]).fields == ["1", "", "2"]
|
||||
# move 2 -> 1
|
||||
d.models.moveField(m, m["flds"][2], 1)
|
||||
@ -88,12 +88,12 @@ def test_templates():
|
||||
t["afmt"] = "{{Front}}"
|
||||
mm.addTemplate(m, t)
|
||||
mm.save(m)
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = "2"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = "2"
|
||||
d.addNote(note)
|
||||
assert d.cardCount() == 2
|
||||
(c, c2) = f.cards()
|
||||
(c, c2) = note.cards()
|
||||
# first card should have first ord
|
||||
assert c.ord == 0
|
||||
assert c2.ord == 1
|
||||
@ -107,7 +107,7 @@ def test_templates():
|
||||
d.models.remTemplate(m, m["tmpls"][0])
|
||||
assert d.cardCount() == 1
|
||||
# and should have updated the other cards' ordinals
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
assert c.ord == 0
|
||||
assert stripHTML(c.q()) == "1"
|
||||
# it shouldn't be possible to orphan notes by removing templates
|
||||
@ -134,11 +134,11 @@ def test_cloze_ordinals():
|
||||
mm.save(m)
|
||||
d.models.remTemplate(m, m["tmpls"][0])
|
||||
|
||||
f = d.newNote()
|
||||
f["Text"] = "{{c1::firstQ::firstA}}{{c2::secondQ::secondA}}"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Text"] = "{{c1::firstQ::firstA}}{{c2::secondQ::secondA}}"
|
||||
d.addNote(note)
|
||||
assert d.cardCount() == 2
|
||||
(c, c2) = f.cards()
|
||||
(c, c2) = note.cards()
|
||||
# first card should have first ord
|
||||
assert c.ord == 0
|
||||
assert c2.ord == 1
|
||||
@ -149,79 +149,83 @@ def test_text():
|
||||
m = d.models.current()
|
||||
m["tmpls"][0]["qfmt"] = "{{text:Front}}"
|
||||
d.models.save(m)
|
||||
f = d.newNote()
|
||||
f["Front"] = "hello<b>world"
|
||||
d.addNote(f)
|
||||
assert "helloworld" in f.cards()[0].q()
|
||||
note = d.newNote()
|
||||
note["Front"] = "hello<b>world"
|
||||
d.addNote(note)
|
||||
assert "helloworld" in note.cards()[0].q()
|
||||
|
||||
|
||||
def test_cloze():
|
||||
d = getEmptyCol()
|
||||
d.models.setCurrent(d.models.byName("Cloze"))
|
||||
f = d.newNote()
|
||||
assert f.model()["name"] == "Cloze"
|
||||
note = d.newNote()
|
||||
assert note.model()["name"] == "Cloze"
|
||||
# a cloze model with no clozes is not empty
|
||||
f["Text"] = "nothing"
|
||||
assert d.addNote(f)
|
||||
note["Text"] = "nothing"
|
||||
assert d.addNote(note)
|
||||
# try with one cloze
|
||||
f = d.newNote()
|
||||
f["Text"] = "hello {{c1::world}}"
|
||||
assert d.addNote(f) == 1
|
||||
assert "hello <span class=cloze>[...]</span>" in f.cards()[0].q()
|
||||
assert "hello <span class=cloze>world</span>" in f.cards()[0].a()
|
||||
note = d.newNote()
|
||||
note["Text"] = "hello {{c1::world}}"
|
||||
assert d.addNote(note) == 1
|
||||
assert "hello <span class=cloze>[...]</span>" in note.cards()[0].q()
|
||||
assert "hello <span class=cloze>world</span>" in note.cards()[0].a()
|
||||
# and with a comment
|
||||
f = d.newNote()
|
||||
f["Text"] = "hello {{c1::world::typical}}"
|
||||
assert d.addNote(f) == 1
|
||||
assert "<span class=cloze>[typical]</span>" in f.cards()[0].q()
|
||||
assert "<span class=cloze>world</span>" in f.cards()[0].a()
|
||||
note = d.newNote()
|
||||
note["Text"] = "hello {{c1::world::typical}}"
|
||||
assert d.addNote(note) == 1
|
||||
assert "<span class=cloze>[typical]</span>" in note.cards()[0].q()
|
||||
assert "<span class=cloze>world</span>" in note.cards()[0].a()
|
||||
# and with 2 clozes
|
||||
f = d.newNote()
|
||||
f["Text"] = "hello {{c1::world}} {{c2::bar}}"
|
||||
assert d.addNote(f) == 2
|
||||
(c1, c2) = f.cards()
|
||||
note = d.newNote()
|
||||
note["Text"] = "hello {{c1::world}} {{c2::bar}}"
|
||||
assert d.addNote(note) == 2
|
||||
(c1, c2) = note.cards()
|
||||
assert "<span class=cloze>[...]</span> bar" in c1.q()
|
||||
assert "<span class=cloze>world</span> bar" in c1.a()
|
||||
assert "world <span class=cloze>[...]</span>" in c2.q()
|
||||
assert "world <span class=cloze>bar</span>" in c2.a()
|
||||
# if there are multiple answers for a single cloze, they are given in a
|
||||
# list
|
||||
f = d.newNote()
|
||||
f["Text"] = "a {{c1::b}} {{c1::c}}"
|
||||
assert d.addNote(f) == 1
|
||||
assert "<span class=cloze>b</span> <span class=cloze>c</span>" in (f.cards()[0].a())
|
||||
note = d.newNote()
|
||||
note["Text"] = "a {{c1::b}} {{c1::c}}"
|
||||
assert d.addNote(note) == 1
|
||||
assert "<span class=cloze>b</span> <span class=cloze>c</span>" in (
|
||||
note.cards()[0].a()
|
||||
)
|
||||
# if we add another cloze, a card should be generated
|
||||
cnt = d.cardCount()
|
||||
f["Text"] = "{{c2::hello}} {{c1::foo}}"
|
||||
f.flush()
|
||||
note["Text"] = "{{c2::hello}} {{c1::foo}}"
|
||||
note.flush()
|
||||
assert d.cardCount() == cnt + 1
|
||||
# 0 or negative indices are not supported
|
||||
f["Text"] += "{{c0::zero}} {{c-1:foo}}"
|
||||
f.flush()
|
||||
assert len(f.cards()) == 2
|
||||
note["Text"] += "{{c0::zero}} {{c-1:foo}}"
|
||||
note.flush()
|
||||
assert len(note.cards()) == 2
|
||||
|
||||
|
||||
def test_cloze_mathjax():
|
||||
d = getEmptyCol()
|
||||
d.models.setCurrent(d.models.byName("Cloze"))
|
||||
f = d.newNote()
|
||||
f[
|
||||
note = d.newNote()
|
||||
note[
|
||||
"Text"
|
||||
] = r"{{c1::ok}} \(2^2\) {{c2::not ok}} \(2^{{c3::2}}\) \(x^3\) {{c4::blah}} {{c5::text with \(x^2\) jax}}"
|
||||
assert d.addNote(f)
|
||||
assert len(f.cards()) == 5
|
||||
assert "class=cloze" in f.cards()[0].q()
|
||||
assert "class=cloze" in f.cards()[1].q()
|
||||
assert "class=cloze" not in f.cards()[2].q()
|
||||
assert "class=cloze" in f.cards()[3].q()
|
||||
assert "class=cloze" in f.cards()[4].q()
|
||||
assert d.addNote(note)
|
||||
assert len(note.cards()) == 5
|
||||
assert "class=cloze" in note.cards()[0].q()
|
||||
assert "class=cloze" in note.cards()[1].q()
|
||||
assert "class=cloze" not in note.cards()[2].q()
|
||||
assert "class=cloze" in note.cards()[3].q()
|
||||
assert "class=cloze" in note.cards()[4].q()
|
||||
|
||||
f = d.newNote()
|
||||
f["Text"] = r"\(a\) {{c1::b}} \[ {{c1::c}} \]"
|
||||
assert d.addNote(f)
|
||||
assert len(f.cards()) == 1
|
||||
note = d.newNote()
|
||||
note["Text"] = r"\(a\) {{c1::b}} \[ {{c1::c}} \]"
|
||||
assert d.addNote(note)
|
||||
assert len(note.cards()) == 1
|
||||
assert (
|
||||
f.cards()[0].q().endswith(r"\(a\) <span class=cloze>[...]</span> \[ [...] \]")
|
||||
note.cards()[0]
|
||||
.q()
|
||||
.endswith(r"\(a\) <span class=cloze>[...]</span> \[ [...] \]")
|
||||
)
|
||||
|
||||
|
||||
@ -231,10 +235,10 @@ def test_typecloze():
|
||||
d.models.setCurrent(m)
|
||||
m["tmpls"][0]["qfmt"] = "{{cloze:Text}}{{type:cloze:Text}}"
|
||||
d.models.save(m)
|
||||
f = d.newNote()
|
||||
f["Text"] = "hello {{c1::world}}"
|
||||
d.addNote(f)
|
||||
assert "[[type:cloze:Text]]" in f.cards()[0].q()
|
||||
note = d.newNote()
|
||||
note["Text"] = "hello {{c1::world}}"
|
||||
d.addNote(note)
|
||||
assert "[[type:cloze:Text]]" in note.cards()[0].q()
|
||||
|
||||
|
||||
def test_chained_mods():
|
||||
@ -251,25 +255,25 @@ def test_chained_mods():
|
||||
mm.save(m)
|
||||
d.models.remTemplate(m, m["tmpls"][0])
|
||||
|
||||
f = d.newNote()
|
||||
note = d.newNote()
|
||||
q1 = '<span style="color:red">phrase</span>'
|
||||
a1 = "<b>sentence</b>"
|
||||
q2 = '<span style="color:red">en chaine</span>'
|
||||
a2 = "<i>chained</i>"
|
||||
f["Text"] = "This {{c1::%s::%s}} demonstrates {{c1::%s::%s}} clozes." % (
|
||||
note["Text"] = "This {{c1::%s::%s}} demonstrates {{c1::%s::%s}} clozes." % (
|
||||
q1,
|
||||
a1,
|
||||
q2,
|
||||
a2,
|
||||
)
|
||||
assert d.addNote(f) == 1
|
||||
assert d.addNote(note) == 1
|
||||
assert (
|
||||
"This <span class=cloze>[sentence]</span> demonstrates <span class=cloze>[chained]</span> clozes."
|
||||
in f.cards()[0].q()
|
||||
in note.cards()[0].q()
|
||||
)
|
||||
assert (
|
||||
"This <span class=cloze>phrase</span> demonstrates <span class=cloze>en chaine</span> clozes."
|
||||
in f.cards()[0].a()
|
||||
in note.cards()[0].a()
|
||||
)
|
||||
|
||||
|
||||
@ -285,40 +289,40 @@ def test_modelChange():
|
||||
mm.addTemplate(m, t)
|
||||
mm.save(m)
|
||||
basic = m
|
||||
f = deck.newNote()
|
||||
f["Front"] = "f"
|
||||
f["Back"] = "b123"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "note"
|
||||
note["Back"] = "b123"
|
||||
deck.addNote(note)
|
||||
# switch fields
|
||||
map = {0: 1, 1: 0}
|
||||
deck.models.change(basic, [f.id], basic, map, None)
|
||||
f.load()
|
||||
assert f["Front"] == "b123"
|
||||
assert f["Back"] == "f"
|
||||
deck.models.change(basic, [note.id], basic, map, None)
|
||||
note.load()
|
||||
assert note["Front"] == "b123"
|
||||
assert note["Back"] == "note"
|
||||
# switch cards
|
||||
c0 = f.cards()[0]
|
||||
c1 = f.cards()[1]
|
||||
c0 = note.cards()[0]
|
||||
c1 = note.cards()[1]
|
||||
assert "b123" in c0.q()
|
||||
assert "f" in c1.q()
|
||||
assert "note" in c1.q()
|
||||
assert c0.ord == 0
|
||||
assert c1.ord == 1
|
||||
deck.models.change(basic, [f.id], basic, None, map)
|
||||
f.load()
|
||||
deck.models.change(basic, [note.id], basic, None, map)
|
||||
note.load()
|
||||
c0.load()
|
||||
c1.load()
|
||||
assert "f" in c0.q()
|
||||
assert "note" in c0.q()
|
||||
assert "b123" in c1.q()
|
||||
assert c0.ord == 1
|
||||
assert c1.ord == 0
|
||||
# .cards() returns cards in order
|
||||
assert f.cards()[0].id == c1.id
|
||||
assert note.cards()[0].id == c1.id
|
||||
# delete first card
|
||||
map = {0: None, 1: 1}
|
||||
if isWin:
|
||||
# The low precision timer on Windows reveals a race condition
|
||||
time.sleep(0.05)
|
||||
deck.models.change(basic, [f.id], basic, None, map)
|
||||
f.load()
|
||||
deck.models.change(basic, [note.id], basic, None, map)
|
||||
note.load()
|
||||
c0.load()
|
||||
# the card was deleted
|
||||
try:
|
||||
@ -327,33 +331,33 @@ def test_modelChange():
|
||||
except NotFoundError:
|
||||
pass
|
||||
# but we have two cards, as a new one was generated
|
||||
assert len(f.cards()) == 2
|
||||
assert len(note.cards()) == 2
|
||||
# an unmapped field becomes blank
|
||||
assert f["Front"] == "b123"
|
||||
assert f["Back"] == "f"
|
||||
deck.models.change(basic, [f.id], basic, map, None)
|
||||
f.load()
|
||||
assert f["Front"] == ""
|
||||
assert f["Back"] == "f"
|
||||
assert note["Front"] == "b123"
|
||||
assert note["Back"] == "note"
|
||||
deck.models.change(basic, [note.id], basic, map, None)
|
||||
note.load()
|
||||
assert note["Front"] == ""
|
||||
assert note["Back"] == "note"
|
||||
# another note to try model conversion
|
||||
f = deck.newNote()
|
||||
f["Front"] = "f2"
|
||||
f["Back"] = "b2"
|
||||
deck.addNote(f)
|
||||
note = deck.newNote()
|
||||
note["Front"] = "f2"
|
||||
note["Back"] = "b2"
|
||||
deck.addNote(note)
|
||||
counts = deck.models.all_use_counts()
|
||||
assert next(c.use_count for c in counts if c.name == "Basic") == 2
|
||||
assert next(c.use_count for c in counts if c.name == "Cloze") == 0
|
||||
map = {0: 0, 1: 1}
|
||||
deck.models.change(basic, [f.id], cloze, map, map)
|
||||
f.load()
|
||||
assert f["Text"] == "f2"
|
||||
assert len(f.cards()) == 2
|
||||
deck.models.change(basic, [note.id], cloze, map, map)
|
||||
note.load()
|
||||
assert note["Text"] == "f2"
|
||||
assert len(note.cards()) == 2
|
||||
# back the other way, with deletion of second ord
|
||||
deck.models.remTemplate(basic, basic["tmpls"][1])
|
||||
assert deck.db.scalar("select count() from cards where nid = ?", f.id) == 2
|
||||
assert deck.db.scalar("select count() from cards where nid = ?", note.id) == 2
|
||||
map = {0: 0}
|
||||
deck.models.change(cloze, [f.id], basic, map, map)
|
||||
assert deck.db.scalar("select count() from cards where nid = ?", f.id) == 1
|
||||
deck.models.change(cloze, [note.id], basic, map, map)
|
||||
assert deck.db.scalar("select count() from cards where nid = ?", note.id) == 1
|
||||
|
||||
|
||||
def test_req():
|
||||
|
@ -37,10 +37,10 @@ def test_new():
|
||||
d.reset()
|
||||
assert d.sched.newCount == 0
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert d.sched.newCount == 1
|
||||
# fetch it
|
||||
@ -64,12 +64,12 @@ def test_new():
|
||||
# t['afmt'] = "{{Front}}"
|
||||
# mm.addTemplate(m, t)
|
||||
# mm.save(m)
|
||||
# f = d.newNote()
|
||||
# f['Front'] = u"2"; f['Back'] = u"2"
|
||||
# d.addNote(f)
|
||||
# f = d.newNote()
|
||||
# f['Front'] = u"3"; f['Back'] = u"3"
|
||||
# d.addNote(f)
|
||||
# note = d.newNote()
|
||||
# note['Front'] = u"2"; note['Back'] = u"2"
|
||||
# d.addNote(note)
|
||||
# note = d.newNote()
|
||||
# note['Front'] = u"3"; note['Back'] = u"3"
|
||||
# d.addNote(note)
|
||||
# d.reset()
|
||||
# qs = ("2", "3", "2", "3")
|
||||
# for n in range(4):
|
||||
@ -83,11 +83,11 @@ def test_newLimits():
|
||||
# add some notes
|
||||
g2 = d.decks.id("Default::foo")
|
||||
for i in range(30):
|
||||
f = d.newNote()
|
||||
f["Front"] = str(i)
|
||||
note = d.newNote()
|
||||
note["Front"] = str(i)
|
||||
if i > 4:
|
||||
f.model()["did"] = g2
|
||||
d.addNote(f)
|
||||
note.model()["did"] = g2
|
||||
d.addNote(note)
|
||||
# give the child deck a different configuration
|
||||
c2 = d.decks.add_config_returning_id("new conf")
|
||||
d.decks.setConf(d.decks.get(g2), c2)
|
||||
@ -113,9 +113,9 @@ def test_newLimits():
|
||||
|
||||
def test_newBoxes():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
c = d.sched.getCard()
|
||||
conf = d.sched._cardConf(c)
|
||||
@ -131,10 +131,10 @@ def test_newBoxes():
|
||||
def test_learn():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
f = d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
note = d.addNote(note)
|
||||
# set as a learn card and rebuild queues
|
||||
d.db.execute("update cards set queue=0, type=0")
|
||||
d.reset()
|
||||
@ -209,12 +209,12 @@ def test_learn():
|
||||
def test_learn_collapsed():
|
||||
d = getEmptyCol()
|
||||
# add 2 notes
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f = d.addNote(f)
|
||||
f = d.newNote()
|
||||
f["Front"] = "2"
|
||||
f = d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note = d.addNote(note)
|
||||
note = d.newNote()
|
||||
note["Front"] = "2"
|
||||
note = d.addNote(note)
|
||||
# set as a learn card and rebuild queues
|
||||
d.db.execute("update cards set queue=0, type=0")
|
||||
d.reset()
|
||||
@ -236,9 +236,9 @@ def test_learn_collapsed():
|
||||
def test_learn_day():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f = d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note = d.addNote(note)
|
||||
d.sched.reset()
|
||||
c = d.sched.getCard()
|
||||
conf = d.sched._cardConf(c)
|
||||
@ -299,12 +299,12 @@ def test_learn_day():
|
||||
def test_reviews():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
# set the card up as a review card, due 8 days ago
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = d.sched.today - 8
|
||||
@ -379,11 +379,11 @@ def test_reviews():
|
||||
|
||||
def test_button_spacing():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# 1 day ivl review card due now
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = d.sched.today
|
||||
@ -404,11 +404,11 @@ def test_overdue_lapse():
|
||||
return
|
||||
d = getEmptyCol() # pylint: disable=unreachable
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# simulate a review that was lapsed and is now due for its normal review
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = 1
|
||||
c.due = -1
|
||||
@ -440,15 +440,15 @@ def test_finished():
|
||||
# nothing due
|
||||
assert "Congratulations" in d.sched.finishedMsg()
|
||||
assert "limit" not in d.sched.finishedMsg()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
# have a new card
|
||||
assert "new cards available" in d.sched.finishedMsg()
|
||||
# turn it into a review
|
||||
d.reset()
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.startTimer()
|
||||
d.sched.answerCard(c, 3)
|
||||
# nothing should be due tomorrow, as it's due in a week
|
||||
@ -458,10 +458,10 @@ def test_finished():
|
||||
|
||||
def test_nextIvl():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
conf = d.decks.confForDid(1)
|
||||
conf["new"]["delays"] = [0.5, 3, 10]
|
||||
@ -518,10 +518,10 @@ def test_nextIvl():
|
||||
|
||||
def test_misc():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
# burying
|
||||
d.sched.buryNote(c.nid)
|
||||
d.reset()
|
||||
@ -533,10 +533,10 @@ def test_misc():
|
||||
|
||||
def test_suspend():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
# suspending
|
||||
d.reset()
|
||||
assert d.sched.getCard()
|
||||
@ -581,10 +581,10 @@ def test_suspend():
|
||||
|
||||
def test_cram():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.ivl = 100
|
||||
c.queue = CARD_TYPE_REV
|
||||
c.type = QUEUE_TYPE_REV
|
||||
@ -693,10 +693,10 @@ def test_cram():
|
||||
|
||||
def test_cram_rem():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
oldDue = f.cards()[0].due
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
oldDue = note.cards()[0].due
|
||||
did = d.decks.newDyn("Cram")
|
||||
d.sched.rebuildDyn(did)
|
||||
d.reset()
|
||||
@ -715,9 +715,9 @@ def test_cram_rem():
|
||||
def test_cram_resched():
|
||||
# add card
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# cram deck
|
||||
did = d.decks.newDyn("Cram")
|
||||
cram = d.decks.get(did)
|
||||
@ -835,10 +835,10 @@ def test_ordcycle():
|
||||
mm.addTemplate(m, t)
|
||||
mm.save(m)
|
||||
# create a new note; it should have 3 cards
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = "1"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = "1"
|
||||
d.addNote(note)
|
||||
assert d.cardCount() == 3
|
||||
d.reset()
|
||||
# ordinals should arrive in order
|
||||
@ -849,10 +849,10 @@ def test_ordcycle():
|
||||
|
||||
def test_counts_idx():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert d.sched.counts() == (1, 0, 0)
|
||||
c = d.sched.getCard()
|
||||
@ -873,9 +873,9 @@ def test_counts_idx():
|
||||
|
||||
def test_repCounts():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
# lrnReps should be accurate on pass/fail
|
||||
assert d.sched.counts() == (1, 0, 0)
|
||||
@ -891,9 +891,9 @@ def test_repCounts():
|
||||
assert d.sched.counts() == (0, 1, 0)
|
||||
d.sched.answerCard(d.sched.getCard(), 2)
|
||||
assert d.sched.counts() == (0, 0, 0)
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
# initial pass should be correct too
|
||||
d.sched.answerCard(d.sched.getCard(), 2)
|
||||
@ -903,17 +903,17 @@ def test_repCounts():
|
||||
d.sched.answerCard(d.sched.getCard(), 3)
|
||||
assert d.sched.counts() == (0, 0, 0)
|
||||
# immediate graduate should work
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
d.sched.answerCard(d.sched.getCard(), 3)
|
||||
assert d.sched.counts() == (0, 0, 0)
|
||||
# and failing a review should too
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = d.sched.today
|
||||
@ -928,10 +928,10 @@ def test_timing():
|
||||
d = getEmptyCol()
|
||||
# add a few review cards, due today
|
||||
for i in range(5):
|
||||
f = d.newNote()
|
||||
f["Front"] = "num" + str(i)
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "num" + str(i)
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = 0
|
||||
@ -962,9 +962,9 @@ def test_timing():
|
||||
def test_collapse():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
# test collapsing
|
||||
c = d.sched.getCard()
|
||||
@ -977,29 +977,29 @@ def test_collapse():
|
||||
def test_deckDue():
|
||||
d = getEmptyCol()
|
||||
# add a note with default deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# and one that's a child
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
default1 = f.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
default1 = note.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(note)
|
||||
# make it a review card
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = 0
|
||||
c.flush()
|
||||
# add one more with a new deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
foobar = f.model()["did"] = d.decks.id("foo::bar")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
foobar = note.model()["did"] = d.decks.id("foo::bar")
|
||||
d.addNote(note)
|
||||
# and one that's a sibling
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
foobaz = f.model()["did"] = d.decks.id("foo::baz")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
foobaz = note.model()["did"] = d.decks.id("foo::baz")
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert len(d.decks.all_names_and_ids()) == 5
|
||||
tree = d.sched.deck_due_tree().children
|
||||
@ -1023,19 +1023,19 @@ def test_deckDue():
|
||||
def test_deckFlow():
|
||||
d = getEmptyCol()
|
||||
# add a note with default deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# and one that's a child
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
default1 = f.model()["did"] = d.decks.id("Default::2")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
default1 = note.model()["did"] = d.decks.id("Default::2")
|
||||
d.addNote(note)
|
||||
# and another that's higher up
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
default1 = f.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
default1 = note.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(note)
|
||||
# should get top level one first, then ::1, then ::2
|
||||
d.reset()
|
||||
assert d.sched.counts() == (3, 0, 0)
|
||||
@ -1048,9 +1048,9 @@ def test_deckFlow():
|
||||
def test_reorder():
|
||||
d = getEmptyCol()
|
||||
# add a note with default deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
f2 = d.newNote()
|
||||
f2["Front"] = "two"
|
||||
d.addNote(f2)
|
||||
@ -1059,12 +1059,12 @@ def test_reorder():
|
||||
# 50/50 chance of being reordered
|
||||
for i in range(20):
|
||||
d.sched.randomizeCards(1)
|
||||
if f.cards()[0].due != f.id:
|
||||
if note.cards()[0].due != note.id:
|
||||
found = True
|
||||
break
|
||||
assert found
|
||||
d.sched.orderCards(1)
|
||||
assert f.cards()[0].due == 1
|
||||
assert note.cards()[0].due == 1
|
||||
# shifting
|
||||
f3 = d.newNote()
|
||||
f3["Front"] = "three"
|
||||
@ -1072,12 +1072,12 @@ def test_reorder():
|
||||
f4 = d.newNote()
|
||||
f4["Front"] = "four"
|
||||
d.addNote(f4)
|
||||
assert f.cards()[0].due == 1
|
||||
assert note.cards()[0].due == 1
|
||||
assert f2.cards()[0].due == 2
|
||||
assert f3.cards()[0].due == 3
|
||||
assert f4.cards()[0].due == 4
|
||||
d.sched.sortCards([f3.cards()[0].id, f4.cards()[0].id], start=1, shift=True)
|
||||
assert f.cards()[0].due == 3
|
||||
assert note.cards()[0].due == 3
|
||||
assert f2.cards()[0].due == 4
|
||||
assert f3.cards()[0].due == 1
|
||||
assert f4.cards()[0].due == 2
|
||||
@ -1085,10 +1085,10 @@ def test_reorder():
|
||||
|
||||
def test_forget():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.type = CARD_TYPE_REV
|
||||
c.ivl = 100
|
||||
@ -1103,10 +1103,10 @@ def test_forget():
|
||||
|
||||
def test_resched():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
d.sched.reschedCards([c.id], 0, 0)
|
||||
c.load()
|
||||
assert c.due == d.sched.today
|
||||
@ -1121,10 +1121,10 @@ def test_resched():
|
||||
def test_norelearn():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = 0
|
||||
@ -1142,11 +1142,11 @@ def test_norelearn():
|
||||
|
||||
def test_failmult():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.ivl = 100
|
||||
|
@ -38,10 +38,10 @@ def test_new():
|
||||
d.reset()
|
||||
assert d.sched.newCount == 0
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert d.sched.newCount == 1
|
||||
# fetch it
|
||||
@ -65,12 +65,12 @@ def test_new():
|
||||
# t['afmt'] = "{{Front}}"
|
||||
# mm.addTemplate(m, t)
|
||||
# mm.save(m)
|
||||
# f = d.newNote()
|
||||
# f['Front'] = u"2"; f['Back'] = u"2"
|
||||
# d.addNote(f)
|
||||
# f = d.newNote()
|
||||
# f['Front'] = u"3"; f['Back'] = u"3"
|
||||
# d.addNote(f)
|
||||
# note = d.newNote()
|
||||
# note['Front'] = u"2"; note['Back'] = u"2"
|
||||
# d.addNote(note)
|
||||
# note = d.newNote()
|
||||
# note['Front'] = u"3"; note['Back'] = u"3"
|
||||
# d.addNote(note)
|
||||
# d.reset()
|
||||
# qs = ("2", "3", "2", "3")
|
||||
# for n in range(4):
|
||||
@ -84,11 +84,11 @@ def test_newLimits():
|
||||
# add some notes
|
||||
g2 = d.decks.id("Default::foo")
|
||||
for i in range(30):
|
||||
f = d.newNote()
|
||||
f["Front"] = str(i)
|
||||
note = d.newNote()
|
||||
note["Front"] = str(i)
|
||||
if i > 4:
|
||||
f.model()["did"] = g2
|
||||
d.addNote(f)
|
||||
note.model()["did"] = g2
|
||||
d.addNote(note)
|
||||
# give the child deck a different configuration
|
||||
c2 = d.decks.add_config_returning_id("new conf")
|
||||
d.decks.setConf(d.decks.get(g2), c2)
|
||||
@ -114,9 +114,9 @@ def test_newLimits():
|
||||
|
||||
def test_newBoxes():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
c = d.sched.getCard()
|
||||
conf = d.sched._cardConf(c)
|
||||
@ -132,10 +132,10 @@ def test_newBoxes():
|
||||
def test_learn():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
f = d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
note = d.addNote(note)
|
||||
# set as a learn card and rebuild queues
|
||||
d.db.execute("update cards set queue=0, type=0")
|
||||
d.reset()
|
||||
@ -194,10 +194,10 @@ def test_learn():
|
||||
|
||||
def test_relearn():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.ivl = 100
|
||||
c.due = d.sched.today
|
||||
c.queue = CARD_TYPE_REV
|
||||
@ -221,10 +221,10 @@ def test_relearn():
|
||||
|
||||
def test_relearn_no_steps():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.ivl = 100
|
||||
c.due = d.sched.today
|
||||
c.queue = CARD_TYPE_REV
|
||||
@ -245,12 +245,12 @@ def test_relearn_no_steps():
|
||||
def test_learn_collapsed():
|
||||
d = getEmptyCol()
|
||||
# add 2 notes
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f = d.addNote(f)
|
||||
f = d.newNote()
|
||||
f["Front"] = "2"
|
||||
f = d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note = d.addNote(note)
|
||||
note = d.newNote()
|
||||
note["Front"] = "2"
|
||||
note = d.addNote(note)
|
||||
# set as a learn card and rebuild queues
|
||||
d.db.execute("update cards set queue=0, type=0")
|
||||
d.reset()
|
||||
@ -272,9 +272,9 @@ def test_learn_collapsed():
|
||||
def test_learn_day():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f = d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note = d.addNote(note)
|
||||
d.sched.reset()
|
||||
c = d.sched.getCard()
|
||||
conf = d.sched._cardConf(c)
|
||||
@ -335,12 +335,12 @@ def test_learn_day():
|
||||
def test_reviews():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
# set the card up as a review card, due 8 days ago
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = d.sched.today - 8
|
||||
@ -431,13 +431,13 @@ def test_review_limits():
|
||||
|
||||
# add some cards
|
||||
for i in range(20):
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
|
||||
# make them reviews
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.queue = CARD_TYPE_REV
|
||||
c.type = QUEUE_TYPE_REV
|
||||
c.due = 0
|
||||
@ -465,11 +465,11 @@ def test_review_limits():
|
||||
|
||||
def test_button_spacing():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# 1 day ivl review card due now
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = d.sched.today
|
||||
@ -496,11 +496,11 @@ def test_overdue_lapse():
|
||||
return
|
||||
d = getEmptyCol() # pylint: disable=unreachable
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# simulate a review that was lapsed and is now due for its normal review
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = 1
|
||||
c.due = -1
|
||||
@ -532,15 +532,15 @@ def test_finished():
|
||||
# nothing due
|
||||
assert "Congratulations" in d.sched.finishedMsg()
|
||||
assert "limit" not in d.sched.finishedMsg()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
# have a new card
|
||||
assert "new cards available" in d.sched.finishedMsg()
|
||||
# turn it into a review
|
||||
d.reset()
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.startTimer()
|
||||
d.sched.answerCard(c, 3)
|
||||
# nothing should be due tomorrow, as it's due in a week
|
||||
@ -550,10 +550,10 @@ def test_finished():
|
||||
|
||||
def test_nextIvl():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
conf = d.decks.confForDid(1)
|
||||
conf["new"]["delays"] = [0.5, 3, 10]
|
||||
@ -613,14 +613,14 @@ def test_nextIvl():
|
||||
|
||||
def test_bury():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
d.addNote(f)
|
||||
c2 = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
d.addNote(note)
|
||||
c2 = note.cards()[0]
|
||||
# burying
|
||||
d.sched.buryCards([c.id], manual=True) # pylint: disable=unexpected-keyword-arg
|
||||
c.load()
|
||||
@ -654,10 +654,10 @@ def test_bury():
|
||||
|
||||
def test_suspend():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
# suspending
|
||||
d.reset()
|
||||
assert d.sched.getCard()
|
||||
@ -704,10 +704,10 @@ def test_suspend():
|
||||
|
||||
def test_filt_reviewing_early_normal():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.ivl = 100
|
||||
c.queue = CARD_TYPE_REV
|
||||
c.type = QUEUE_TYPE_REV
|
||||
@ -761,9 +761,9 @@ def test_filt_reviewing_early_normal():
|
||||
def test_filt_keep_lrn_state():
|
||||
d = getEmptyCol()
|
||||
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
|
||||
# fail the card outside filtered deck
|
||||
c = d.sched.getCard()
|
||||
@ -805,10 +805,10 @@ def test_filt_keep_lrn_state():
|
||||
def test_preview():
|
||||
# add cards
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
orig = copy.copy(c)
|
||||
f2 = d.newNote()
|
||||
f2["Front"] = "two"
|
||||
@ -867,10 +867,10 @@ def test_ordcycle():
|
||||
mm.addTemplate(m, t)
|
||||
mm.save(m)
|
||||
# create a new note; it should have 3 cards
|
||||
f = d.newNote()
|
||||
f["Front"] = "1"
|
||||
f["Back"] = "1"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "1"
|
||||
note["Back"] = "1"
|
||||
d.addNote(note)
|
||||
assert d.cardCount() == 3
|
||||
d.reset()
|
||||
# ordinals should arrive in order
|
||||
@ -881,10 +881,10 @@ def test_ordcycle():
|
||||
|
||||
def test_counts_idx():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert d.sched.counts() == (1, 0, 0)
|
||||
c = d.sched.getCard()
|
||||
@ -905,9 +905,9 @@ def test_counts_idx():
|
||||
|
||||
def test_repCounts():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
# lrnReps should be accurate on pass/fail
|
||||
assert d.sched.counts() == (1, 0, 0)
|
||||
@ -923,9 +923,9 @@ def test_repCounts():
|
||||
assert d.sched.counts() == (0, 1, 0)
|
||||
d.sched.answerCard(d.sched.getCard(), 3)
|
||||
assert d.sched.counts() == (0, 0, 0)
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
# initial pass should be correct too
|
||||
d.sched.answerCard(d.sched.getCard(), 3)
|
||||
@ -935,17 +935,17 @@ def test_repCounts():
|
||||
d.sched.answerCard(d.sched.getCard(), 4)
|
||||
assert d.sched.counts() == (0, 0, 0)
|
||||
# immediate graduate should work
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
d.sched.answerCard(d.sched.getCard(), 4)
|
||||
assert d.sched.counts() == (0, 0, 0)
|
||||
# and failing a review should too
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = d.sched.today
|
||||
@ -960,10 +960,10 @@ def test_timing():
|
||||
d = getEmptyCol()
|
||||
# add a few review cards, due today
|
||||
for i in range(5):
|
||||
f = d.newNote()
|
||||
f["Front"] = "num" + str(i)
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "num" + str(i)
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = 0
|
||||
@ -986,9 +986,9 @@ def test_timing():
|
||||
def test_collapse():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
# test collapsing
|
||||
c = d.sched.getCard()
|
||||
@ -1001,29 +1001,29 @@ def test_collapse():
|
||||
def test_deckDue():
|
||||
d = getEmptyCol()
|
||||
# add a note with default deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# and one that's a child
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
default1 = f.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
default1 = note.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(note)
|
||||
# make it a review card
|
||||
c = f.cards()[0]
|
||||
c = note.cards()[0]
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = 0
|
||||
c.flush()
|
||||
# add one more with a new deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
foobar = f.model()["did"] = d.decks.id("foo::bar")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
foobar = note.model()["did"] = d.decks.id("foo::bar")
|
||||
d.addNote(note)
|
||||
# and one that's a sibling
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
foobaz = f.model()["did"] = d.decks.id("foo::baz")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
foobaz = note.model()["did"] = d.decks.id("foo::baz")
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert len(d.decks.all_names_and_ids()) == 5
|
||||
tree = d.sched.deck_due_tree().children
|
||||
@ -1057,19 +1057,19 @@ def test_deckTree():
|
||||
def test_deckFlow():
|
||||
d = getEmptyCol()
|
||||
# add a note with default deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
# and one that's a child
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
default1 = f.model()["did"] = d.decks.id("Default::2")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
default1 = note.model()["did"] = d.decks.id("Default::2")
|
||||
d.addNote(note)
|
||||
# and another that's higher up
|
||||
f = d.newNote()
|
||||
f["Front"] = "three"
|
||||
default1 = f.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "three"
|
||||
default1 = note.model()["did"] = d.decks.id("Default::1")
|
||||
d.addNote(note)
|
||||
# should get top level one first, then ::1, then ::2
|
||||
d.reset()
|
||||
assert d.sched.counts() == (3, 0, 0)
|
||||
@ -1082,9 +1082,9 @@ def test_deckFlow():
|
||||
def test_reorder():
|
||||
d = getEmptyCol()
|
||||
# add a note with default deck
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
f2 = d.newNote()
|
||||
f2["Front"] = "two"
|
||||
d.addNote(f2)
|
||||
@ -1093,12 +1093,12 @@ def test_reorder():
|
||||
# 50/50 chance of being reordered
|
||||
for i in range(20):
|
||||
d.sched.randomizeCards(1)
|
||||
if f.cards()[0].due != f.id:
|
||||
if note.cards()[0].due != note.id:
|
||||
found = True
|
||||
break
|
||||
assert found
|
||||
d.sched.orderCards(1)
|
||||
assert f.cards()[0].due == 1
|
||||
assert note.cards()[0].due == 1
|
||||
# shifting
|
||||
f3 = d.newNote()
|
||||
f3["Front"] = "three"
|
||||
@ -1106,12 +1106,12 @@ def test_reorder():
|
||||
f4 = d.newNote()
|
||||
f4["Front"] = "four"
|
||||
d.addNote(f4)
|
||||
assert f.cards()[0].due == 1
|
||||
assert note.cards()[0].due == 1
|
||||
assert f2.cards()[0].due == 2
|
||||
assert f3.cards()[0].due == 3
|
||||
assert f4.cards()[0].due == 4
|
||||
d.sched.sortCards([f3.cards()[0].id, f4.cards()[0].id], start=1, shift=True)
|
||||
assert f.cards()[0].due == 3
|
||||
assert note.cards()[0].due == 3
|
||||
assert f2.cards()[0].due == 4
|
||||
assert f3.cards()[0].due == 1
|
||||
assert f4.cards()[0].due == 2
|
||||
@ -1119,10 +1119,10 @@ def test_reorder():
|
||||
|
||||
def test_forget():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.type = CARD_TYPE_REV
|
||||
c.ivl = 100
|
||||
@ -1137,10 +1137,10 @@ def test_forget():
|
||||
|
||||
def test_resched():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
d.sched.reschedCards([c.id], 0, 0)
|
||||
c.load()
|
||||
assert c.due == d.sched.today
|
||||
@ -1155,10 +1155,10 @@ def test_resched():
|
||||
def test_norelearn():
|
||||
d = getEmptyCol()
|
||||
# add a note
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.due = 0
|
||||
@ -1176,11 +1176,11 @@ def test_norelearn():
|
||||
|
||||
def test_failmult():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.type = CARD_TYPE_REV
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.ivl = 100
|
||||
@ -1264,11 +1264,11 @@ def test_negativeDueFilter():
|
||||
d = getEmptyCol()
|
||||
|
||||
# card due prior to collection date
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
c.due = -5
|
||||
c.queue = QUEUE_TYPE_REV
|
||||
c.ivl = 5
|
||||
@ -1288,10 +1288,10 @@ def test_negativeDueFilter():
|
||||
# and it should be logged properly
|
||||
def test_initial_repeat():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
f["Back"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
note["Back"] = "two"
|
||||
d.addNote(note)
|
||||
|
||||
d.reset()
|
||||
c = d.sched.getCard()
|
||||
|
@ -9,10 +9,10 @@ from tests.shared import getEmptyCol
|
||||
|
||||
def test_stats():
|
||||
d = getEmptyCol()
|
||||
f = d.newNote()
|
||||
f["Front"] = "foo"
|
||||
d.addNote(f)
|
||||
c = f.cards()[0]
|
||||
note = d.newNote()
|
||||
note["Front"] = "foo"
|
||||
d.addNote(note)
|
||||
c = note.cards()[0]
|
||||
# card stats
|
||||
assert d.cardStats(c)
|
||||
d.reset()
|
||||
@ -32,6 +32,6 @@ def test_graphs():
|
||||
d = getEmptyCol()
|
||||
g = d.stats()
|
||||
rep = g.report()
|
||||
with open(os.path.join(dir, "test.html"), "w", encoding="UTF-8") as f:
|
||||
f.write(rep)
|
||||
with open(os.path.join(dir, "test.html"), "w", encoding="UTF-8") as note:
|
||||
note.write(rep)
|
||||
return
|
||||
|
@ -7,9 +7,9 @@ def test_deferred_frontside():
|
||||
m["tmpls"][0]["qfmt"] = "{{custom:Front}}"
|
||||
d.models.save(m)
|
||||
|
||||
f = d.newNote()
|
||||
f["Front"] = "xxtest"
|
||||
f["Back"] = ""
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "xxtest"
|
||||
note["Back"] = ""
|
||||
d.addNote(note)
|
||||
|
||||
assert "xxtest" in f.cards()[0].a()
|
||||
assert "xxtest" in note.cards()[0].a()
|
||||
|
@ -34,9 +34,9 @@ def test_op():
|
||||
assert not d.undoName()
|
||||
# and a review will, too
|
||||
d.save("add")
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert d.undoName() == "add"
|
||||
c = d.sched.getCard()
|
||||
@ -47,9 +47,9 @@ def test_op():
|
||||
def test_review():
|
||||
d = getEmptyCol()
|
||||
d.conf["counts"] = COUNT_REMAINING
|
||||
f = d.newNote()
|
||||
f["Front"] = "one"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "one"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert not d.undoName()
|
||||
# answer
|
||||
@ -70,9 +70,9 @@ def test_review():
|
||||
assert c.left != 1001
|
||||
assert not d.undoName()
|
||||
# we should be able to undo multiple answers too
|
||||
f = d.newNote()
|
||||
f["Front"] = "two"
|
||||
d.addNote(f)
|
||||
note = d.newNote()
|
||||
note["Front"] = "two"
|
||||
d.addNote(note)
|
||||
d.reset()
|
||||
assert d.sched.counts() == (2, 0, 0)
|
||||
c = d.sched.getCard()
|
||||
|
Loading…
Reference in New Issue
Block a user