mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
f2->note2 in test
Obtained by ``` sed -i "s/\bf2\b/note2/g" pylib/tests/*py qt/tests/*py ```
This commit is contained in:
parent
4c25835d27
commit
425b82e6e7
4 changed files with 39 additions and 39 deletions
|
@ -74,13 +74,13 @@ def test_noteAddDelete():
|
||||||
# it should not be a duplicate
|
# it should not be a duplicate
|
||||||
assert not note.dupeOrEmpty()
|
assert not note.dupeOrEmpty()
|
||||||
# now let's make a duplicate
|
# now let's make a duplicate
|
||||||
f2 = deck.newNote()
|
note2 = deck.newNote()
|
||||||
f2["Front"] = "one"
|
note2["Front"] = "one"
|
||||||
f2["Back"] = ""
|
note2["Back"] = ""
|
||||||
assert f2.dupeOrEmpty()
|
assert note2.dupeOrEmpty()
|
||||||
# empty first field should not be permitted either
|
# empty first field should not be permitted either
|
||||||
f2["Front"] = " "
|
note2["Front"] = " "
|
||||||
assert f2.dupeOrEmpty()
|
assert note2.dupeOrEmpty()
|
||||||
|
|
||||||
|
|
||||||
def test_fieldChecksum():
|
def test_fieldChecksum():
|
||||||
|
@ -101,15 +101,15 @@ def test_addDelTags():
|
||||||
note = deck.newNote()
|
note = deck.newNote()
|
||||||
note["Front"] = "1"
|
note["Front"] = "1"
|
||||||
deck.addNote(note)
|
deck.addNote(note)
|
||||||
f2 = deck.newNote()
|
note2 = deck.newNote()
|
||||||
f2["Front"] = "2"
|
note2["Front"] = "2"
|
||||||
deck.addNote(f2)
|
deck.addNote(note2)
|
||||||
# adding for a given id
|
# adding for a given id
|
||||||
deck.tags.bulkAdd([note.id], "foo")
|
deck.tags.bulkAdd([note.id], "foo")
|
||||||
note.load()
|
note.load()
|
||||||
f2.load()
|
note2.load()
|
||||||
assert "foo" in note.tags
|
assert "foo" in note.tags
|
||||||
assert "foo" not in f2.tags
|
assert "foo" not in note2.tags
|
||||||
# should be canonified
|
# should be canonified
|
||||||
deck.tags.bulkAdd([note.id], "foo aaa")
|
deck.tags.bulkAdd([note.id], "foo aaa")
|
||||||
note.load()
|
note.load()
|
||||||
|
|
|
@ -235,25 +235,25 @@ def test_findReplace():
|
||||||
note["Front"] = "foo"
|
note["Front"] = "foo"
|
||||||
note["Back"] = "bar"
|
note["Back"] = "bar"
|
||||||
deck.addNote(note)
|
deck.addNote(note)
|
||||||
f2 = deck.newNote()
|
note2 = deck.newNote()
|
||||||
f2["Front"] = "baz"
|
note2["Front"] = "baz"
|
||||||
f2["Back"] = "foo"
|
note2["Back"] = "foo"
|
||||||
deck.addNote(f2)
|
deck.addNote(note2)
|
||||||
nids = [note.id, f2.id]
|
nids = [note.id, note2.id]
|
||||||
# should do nothing
|
# should do nothing
|
||||||
assert deck.findReplace(nids, "abc", "123") == 0
|
assert deck.findReplace(nids, "abc", "123") == 0
|
||||||
# global replace
|
# global replace
|
||||||
assert deck.findReplace(nids, "foo", "qux") == 2
|
assert deck.findReplace(nids, "foo", "qux") == 2
|
||||||
note.load()
|
note.load()
|
||||||
assert note["Front"] == "qux"
|
assert note["Front"] == "qux"
|
||||||
f2.load()
|
note2.load()
|
||||||
assert f2["Back"] == "qux"
|
assert note2["Back"] == "qux"
|
||||||
# single field replace
|
# single field replace
|
||||||
assert deck.findReplace(nids, "qux", "foo", field="Front") == 1
|
assert deck.findReplace(nids, "qux", "foo", field="Front") == 1
|
||||||
note.load()
|
note.load()
|
||||||
assert note["Front"] == "foo"
|
assert note["Front"] == "foo"
|
||||||
f2.load()
|
note2.load()
|
||||||
assert f2["Back"] == "qux"
|
assert note2["Back"] == "qux"
|
||||||
# regex replace
|
# regex replace
|
||||||
assert deck.findReplace(nids, "B.r", "reg") == 0
|
assert deck.findReplace(nids, "B.r", "reg") == 0
|
||||||
note.load()
|
note.load()
|
||||||
|
@ -269,10 +269,10 @@ def test_findDupes():
|
||||||
note["Front"] = "foo"
|
note["Front"] = "foo"
|
||||||
note["Back"] = "bar"
|
note["Back"] = "bar"
|
||||||
deck.addNote(note)
|
deck.addNote(note)
|
||||||
f2 = deck.newNote()
|
note2 = deck.newNote()
|
||||||
f2["Front"] = "baz"
|
note2["Front"] = "baz"
|
||||||
f2["Back"] = "bar"
|
note2["Back"] = "bar"
|
||||||
deck.addNote(f2)
|
deck.addNote(note2)
|
||||||
f3 = deck.newNote()
|
f3 = deck.newNote()
|
||||||
f3["Front"] = "quux"
|
f3["Front"] = "quux"
|
||||||
f3["Back"] = "bar"
|
f3["Back"] = "bar"
|
||||||
|
|
|
@ -1051,10 +1051,10 @@ def test_reorder():
|
||||||
note = d.newNote()
|
note = d.newNote()
|
||||||
note["Front"] = "one"
|
note["Front"] = "one"
|
||||||
d.addNote(note)
|
d.addNote(note)
|
||||||
f2 = d.newNote()
|
note2 = d.newNote()
|
||||||
f2["Front"] = "two"
|
note2["Front"] = "two"
|
||||||
d.addNote(f2)
|
d.addNote(note2)
|
||||||
assert f2.cards()[0].due == 2
|
assert note2.cards()[0].due == 2
|
||||||
found = False
|
found = False
|
||||||
# 50/50 chance of being reordered
|
# 50/50 chance of being reordered
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
|
@ -1073,12 +1073,12 @@ def test_reorder():
|
||||||
f4["Front"] = "four"
|
f4["Front"] = "four"
|
||||||
d.addNote(f4)
|
d.addNote(f4)
|
||||||
assert note.cards()[0].due == 1
|
assert note.cards()[0].due == 1
|
||||||
assert f2.cards()[0].due == 2
|
assert note2.cards()[0].due == 2
|
||||||
assert f3.cards()[0].due == 3
|
assert f3.cards()[0].due == 3
|
||||||
assert f4.cards()[0].due == 4
|
assert f4.cards()[0].due == 4
|
||||||
d.sched.sortCards([f3.cards()[0].id, f4.cards()[0].id], start=1, shift=True)
|
d.sched.sortCards([f3.cards()[0].id, f4.cards()[0].id], start=1, shift=True)
|
||||||
assert note.cards()[0].due == 3
|
assert note.cards()[0].due == 3
|
||||||
assert f2.cards()[0].due == 4
|
assert note2.cards()[0].due == 4
|
||||||
assert f3.cards()[0].due == 1
|
assert f3.cards()[0].due == 1
|
||||||
assert f4.cards()[0].due == 2
|
assert f4.cards()[0].due == 2
|
||||||
|
|
||||||
|
|
|
@ -810,9 +810,9 @@ def test_preview():
|
||||||
d.addNote(note)
|
d.addNote(note)
|
||||||
c = note.cards()[0]
|
c = note.cards()[0]
|
||||||
orig = copy.copy(c)
|
orig = copy.copy(c)
|
||||||
f2 = d.newNote()
|
note2 = d.newNote()
|
||||||
f2["Front"] = "two"
|
note2["Front"] = "two"
|
||||||
d.addNote(f2)
|
d.addNote(note2)
|
||||||
# cram deck
|
# cram deck
|
||||||
did = d.decks.newDyn("Cram")
|
did = d.decks.newDyn("Cram")
|
||||||
cram = d.decks.get(did)
|
cram = d.decks.get(did)
|
||||||
|
@ -1085,10 +1085,10 @@ def test_reorder():
|
||||||
note = d.newNote()
|
note = d.newNote()
|
||||||
note["Front"] = "one"
|
note["Front"] = "one"
|
||||||
d.addNote(note)
|
d.addNote(note)
|
||||||
f2 = d.newNote()
|
note2 = d.newNote()
|
||||||
f2["Front"] = "two"
|
note2["Front"] = "two"
|
||||||
d.addNote(f2)
|
d.addNote(note2)
|
||||||
assert f2.cards()[0].due == 2
|
assert note2.cards()[0].due == 2
|
||||||
found = False
|
found = False
|
||||||
# 50/50 chance of being reordered
|
# 50/50 chance of being reordered
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
|
@ -1107,12 +1107,12 @@ def test_reorder():
|
||||||
f4["Front"] = "four"
|
f4["Front"] = "four"
|
||||||
d.addNote(f4)
|
d.addNote(f4)
|
||||||
assert note.cards()[0].due == 1
|
assert note.cards()[0].due == 1
|
||||||
assert f2.cards()[0].due == 2
|
assert note2.cards()[0].due == 2
|
||||||
assert f3.cards()[0].due == 3
|
assert f3.cards()[0].due == 3
|
||||||
assert f4.cards()[0].due == 4
|
assert f4.cards()[0].due == 4
|
||||||
d.sched.sortCards([f3.cards()[0].id, f4.cards()[0].id], start=1, shift=True)
|
d.sched.sortCards([f3.cards()[0].id, f4.cards()[0].id], start=1, shift=True)
|
||||||
assert note.cards()[0].due == 3
|
assert note.cards()[0].due == 3
|
||||||
assert f2.cards()[0].due == 4
|
assert note2.cards()[0].due == 4
|
||||||
assert f3.cards()[0].due == 1
|
assert f3.cards()[0].due == 1
|
||||||
assert f4.cards()[0].due == 2
|
assert f4.cards()[0].due == 2
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue