From 23eeb845567c1497bc68c70e7412eaa1b3c0a2aa Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Sun, 19 Jul 2020 05:27:31 +0200 Subject: [PATCH] Uses constant in tests --- pylib/tests/test_find.py | 2 +- pylib/tests/test_importing.py | 3 ++- pylib/tests/test_schedv1.py | 10 +++++----- pylib/tests/test_schedv2.py | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pylib/tests/test_find.py b/pylib/tests/test_find.py index 0b22d6fdb..d9b7f76f2 100644 --- a/pylib/tests/test_find.py +++ b/pylib/tests/test_find.py @@ -83,7 +83,7 @@ def test_findCards(): c.flush() assert col.findCards("is:due") == [c.id] assert len(col.findCards("-is:due")) == 4 - c.queue = -1 + c.queue = QUEUE_TYPE_SUSPENDED # ensure this card gets a later mod time c.flush() col.db.execute("update cards set mod = mod + 1 where id = ?", c.id) diff --git a/pylib/tests/test_importing.py b/pylib/tests/test_importing.py index 44de46928..1bd66c0c1 100644 --- a/pylib/tests/test_importing.py +++ b/pylib/tests/test_importing.py @@ -5,6 +5,7 @@ from tempfile import NamedTemporaryFile import pytest +from anki.consts import * from anki.importing import ( Anki2Importer, AnkiPackageImporter, @@ -328,5 +329,5 @@ def test_mnemo(): i.run() assert col.cardCount() == 7 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() diff --git a/pylib/tests/test_schedv1.py b/pylib/tests/test_schedv1.py index 0e52b92c5..3553cce1a 100644 --- a/pylib/tests/test_schedv1.py +++ b/pylib/tests/test_schedv1.py @@ -179,8 +179,8 @@ def test_learn(): assert c.due == col.sched.today + 1 assert c.ivl == 1 # or normal removal - c.type = 0 - c.queue = 1 + c.type = CARD_TYPE_NEW + c.queue = QUEUE_TYPE_LRN col.sched.answerCard(c, 3) assert c.type == CARD_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 # now failed card handling c.type = CARD_TYPE_REV - c.queue = 1 + c.queue = QUEUE_TYPE_LRN c.odue = 123 col.sched.answerCard(c, 3) assert c.due == 123 @@ -197,7 +197,7 @@ def test_learn(): assert c.queue == QUEUE_TYPE_REV # we should be able to remove manually, too c.type = CARD_TYPE_REV - c.queue = 1 + c.queue = QUEUE_TYPE_LRN c.odue = 321 c.flush() 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 c = note.cards()[0] c.type = CARD_TYPE_REV - c.queue = 1 + c.queue = QUEUE_TYPE_LRN c.due = -1 c.odue = -1 c.factor = STARTING_FACTOR diff --git a/pylib/tests/test_schedv2.py b/pylib/tests/test_schedv2.py index a32da9ec0..8bf854297 100644 --- a/pylib/tests/test_schedv2.py +++ b/pylib/tests/test_schedv2.py @@ -182,8 +182,8 @@ def test_learn(): assert c.due == col.sched.today + 1 assert c.ivl == 1 # or normal removal - c.type = 0 - c.queue = 1 + c.type = CARD_TYPE_NEW + c.queue = QUEUE_TYPE_LRN col.sched.answerCard(c, 4) assert c.type == CARD_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 c = note.cards()[0] c.type = CARD_TYPE_REV - c.queue = 1 + c.queue = QUEUE_TYPE_LRN c.due = -1 c.odue = -1 c.factor = STARTING_FACTOR