mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
card tests
This commit is contained in:
parent
f15cb23c41
commit
6cfe112f91
1 changed files with 22 additions and 2 deletions
|
@ -47,7 +47,7 @@ def setup_basic(loadDecks=None):
|
||||||
client = Syncer(deck1, server)
|
client = Syncer(deck1, server)
|
||||||
# for testing, don't add the 10 minute padding
|
# for testing, don't add the 10 minute padding
|
||||||
def _lastSync(lsyn, rsyn):
|
def _lastSync(lsyn, rsyn):
|
||||||
return min(lsyn, rsyn)
|
return min(lsyn, rsyn) - 1
|
||||||
client._lastSync = _lastSync
|
client._lastSync = _lastSync
|
||||||
|
|
||||||
def setup_modified():
|
def setup_modified():
|
||||||
|
@ -126,12 +126,32 @@ def test_facts():
|
||||||
# deletions too
|
# deletions too
|
||||||
assert deck1.db.scalar("select 1 from facts where id = ?", fid)
|
assert deck1.db.scalar("select 1 from facts where id = ?", fid)
|
||||||
deck1.remFacts([fid])
|
deck1.remFacts([fid])
|
||||||
deck1.lastSync = deck2.lastSync = intTime() - 1
|
|
||||||
deck1.save(mod=intTime()+1)
|
deck1.save(mod=intTime()+1)
|
||||||
assert client.sync() == "success"
|
assert client.sync() == "success"
|
||||||
assert not deck1.db.scalar("select 1 from facts where id = ?", fid)
|
assert not deck1.db.scalar("select 1 from facts where id = ?", fid)
|
||||||
assert not deck2.db.scalar("select 1 from facts where id = ?", fid)
|
assert not deck2.db.scalar("select 1 from facts where id = ?", fid)
|
||||||
|
|
||||||
|
@nose.with_setup(setup_modified)
|
||||||
|
def test_cards():
|
||||||
|
test_sync()
|
||||||
|
fid = deck1.db.scalar("select id from facts")
|
||||||
|
fact = deck1.getFact(fid)
|
||||||
|
card = fact.cards()[0]
|
||||||
|
# answer the card locally
|
||||||
|
card.startTimer()
|
||||||
|
deck1.sched.answerCard(card, 4)
|
||||||
|
assert card.reps == 2
|
||||||
|
deck1.save(mod=intTime()+1)
|
||||||
|
assert deck2.getCard(card.id).reps == 1
|
||||||
|
assert client.sync() == "success"
|
||||||
|
assert deck2.getCard(card.id).reps == 2
|
||||||
|
deck1.remCards([card.id])
|
||||||
|
deck1.save(mod=intTime()+1)
|
||||||
|
assert deck2.db.scalar("select 1 from cards where id = ?", card.id)
|
||||||
|
assert client.sync() == "success"
|
||||||
|
assert not deck2.db.scalar("select 1 from cards where id = ?", card.id)
|
||||||
|
|
||||||
|
|
||||||
def _test_speed():
|
def _test_speed():
|
||||||
t = time.time()
|
t = time.time()
|
||||||
setup_basic([os.path.expanduser("~/rapid.anki"),
|
setup_basic([os.path.expanduser("~/rapid.anki"),
|
||||||
|
|
Loading…
Reference in a new issue