Uses constant in tests

This commit is contained in:
Arthur Milchior 2020-07-19 05:27:31 +02:00
parent f04ea6904d
commit 23eeb84556
4 changed files with 11 additions and 10 deletions

View file

@ -83,7 +83,7 @@ def test_findCards():
c.flush() c.flush()
assert col.findCards("is:due") == [c.id] assert col.findCards("is:due") == [c.id]
assert len(col.findCards("-is:due")) == 4 assert len(col.findCards("-is:due")) == 4
c.queue = -1 c.queue = QUEUE_TYPE_SUSPENDED
# ensure this card gets a later mod time # ensure this card gets a later mod time
c.flush() c.flush()
col.db.execute("update cards set mod = mod + 1 where id = ?", c.id) col.db.execute("update cards set mod = mod + 1 where id = ?", c.id)

View file

@ -5,6 +5,7 @@ from tempfile import NamedTemporaryFile
import pytest import pytest
from anki.consts import *
from anki.importing import ( from anki.importing import (
Anki2Importer, Anki2Importer,
AnkiPackageImporter, AnkiPackageImporter,
@ -328,5 +329,5 @@ def test_mnemo():
i.run() i.run()
assert col.cardCount() == 7 assert col.cardCount() == 7
assert "a_longer_tag" in col.tags.all() assert "a_longer_tag" in col.tags.all()
assert col.db.scalar("select count() from cards where type = 0") == 1 assert col.db.scalar(f"select count() from cards where type = {CARD_TYPE_NEW}") == 1
col.close() col.close()

View file

@ -179,8 +179,8 @@ def test_learn():
assert c.due == col.sched.today + 1 assert c.due == col.sched.today + 1
assert c.ivl == 1 assert c.ivl == 1
# or normal removal # or normal removal
c.type = 0 c.type = CARD_TYPE_NEW
c.queue = 1 c.queue = QUEUE_TYPE_LRN
col.sched.answerCard(c, 3) col.sched.answerCard(c, 3)
assert c.type == CARD_TYPE_REV assert c.type == CARD_TYPE_REV
assert c.queue == QUEUE_TYPE_REV assert c.queue == QUEUE_TYPE_REV
@ -189,7 +189,7 @@ def test_learn():
assert col.db.scalar("select count() from revlog where type = 0") == 5 assert col.db.scalar("select count() from revlog where type = 0") == 5
# now failed card handling # now failed card handling
c.type = CARD_TYPE_REV c.type = CARD_TYPE_REV
c.queue = 1 c.queue = QUEUE_TYPE_LRN
c.odue = 123 c.odue = 123
col.sched.answerCard(c, 3) col.sched.answerCard(c, 3)
assert c.due == 123 assert c.due == 123
@ -197,7 +197,7 @@ def test_learn():
assert c.queue == QUEUE_TYPE_REV assert c.queue == QUEUE_TYPE_REV
# we should be able to remove manually, too # we should be able to remove manually, too
c.type = CARD_TYPE_REV c.type = CARD_TYPE_REV
c.queue = 1 c.queue = QUEUE_TYPE_LRN
c.odue = 321 c.odue = 321
c.flush() c.flush()
col.sched.removeLrn() col.sched.removeLrn()
@ -410,7 +410,7 @@ def test_overdue_lapse():
# simulate a review that was lapsed and is now due for its normal review # simulate a review that was lapsed and is now due for its normal review
c = note.cards()[0] c = note.cards()[0]
c.type = CARD_TYPE_REV c.type = CARD_TYPE_REV
c.queue = 1 c.queue = QUEUE_TYPE_LRN
c.due = -1 c.due = -1
c.odue = -1 c.odue = -1
c.factor = STARTING_FACTOR c.factor = STARTING_FACTOR

View file

@ -182,8 +182,8 @@ def test_learn():
assert c.due == col.sched.today + 1 assert c.due == col.sched.today + 1
assert c.ivl == 1 assert c.ivl == 1
# or normal removal # or normal removal
c.type = 0 c.type = CARD_TYPE_NEW
c.queue = 1 c.queue = QUEUE_TYPE_LRN
col.sched.answerCard(c, 4) col.sched.answerCard(c, 4)
assert c.type == CARD_TYPE_REV assert c.type == CARD_TYPE_REV
assert c.queue == QUEUE_TYPE_REV assert c.queue == QUEUE_TYPE_REV
@ -502,7 +502,7 @@ def test_overdue_lapse():
# simulate a review that was lapsed and is now due for its normal review # simulate a review that was lapsed and is now due for its normal review
c = note.cards()[0] c = note.cards()[0]
c.type = CARD_TYPE_REV c.type = CARD_TYPE_REV
c.queue = 1 c.queue = QUEUE_TYPE_LRN
c.due = -1 c.due = -1
c.odue = -1 c.odue = -1
c.factor = STARTING_FACTOR c.factor = STARTING_FACTOR