mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
skip the 600 second pad during testing
This commit is contained in:
parent
85a2bb6193
commit
f15cb23c41
2 changed files with 11 additions and 1 deletions
|
@ -68,7 +68,7 @@ class Syncer(object):
|
||||||
elif lscm != rscm:
|
elif lscm != rscm:
|
||||||
return "fullSync"
|
return "fullSync"
|
||||||
# find last sync time minus 10 mins for clock drift
|
# find last sync time minus 10 mins for clock drift
|
||||||
self.ls = min(lsyn, rsyn) - 600
|
self.ls = self._lastSync(lsyn, rsyn)
|
||||||
self.lnewer = self.lmod > self.rmod
|
self.lnewer = self.lmod > self.rmod
|
||||||
# get local changes and switch to full sync if there were too many
|
# get local changes and switch to full sync if there were too many
|
||||||
self.status("getLocal")
|
self.status("getLocal")
|
||||||
|
@ -89,6 +89,9 @@ class Syncer(object):
|
||||||
self.finish(mod)
|
self.finish(mod)
|
||||||
return "success"
|
return "success"
|
||||||
|
|
||||||
|
def _lastSync(self, lsyn, rsyn):
|
||||||
|
return min(lsyn, rsyn) - 600
|
||||||
|
|
||||||
def times(self):
|
def times(self):
|
||||||
return (self.deck.mod, self.deck.scm, self.deck.lastSync)
|
return (self.deck.mod, self.deck.scm, self.deck.lastSync)
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,10 @@ def setup_basic(loadDecks=None):
|
||||||
deck1.save(); deck2.save()
|
deck1.save(); deck2.save()
|
||||||
server = LocalServer(deck2)
|
server = LocalServer(deck2)
|
||||||
client = Syncer(deck1, server)
|
client = Syncer(deck1, server)
|
||||||
|
# for testing, don't add the 10 minute padding
|
||||||
|
def _lastSync(lsyn, rsyn):
|
||||||
|
return min(lsyn, rsyn)
|
||||||
|
client._lastSync = _lastSync
|
||||||
|
|
||||||
def setup_modified():
|
def setup_modified():
|
||||||
setup_basic()
|
setup_basic()
|
||||||
|
@ -77,6 +81,7 @@ def test_sync():
|
||||||
# last sync times and mod times should agree
|
# last sync times and mod times should agree
|
||||||
assert deck1.mod == deck2.mod
|
assert deck1.mod == deck2.mod
|
||||||
assert deck1.lastSync == deck2.lastSync
|
assert deck1.lastSync == deck2.lastSync
|
||||||
|
assert deck1.mod == deck1.lastSync
|
||||||
assert deck1.lastSync != origLs
|
assert deck1.lastSync != origLs
|
||||||
# because everything was created separately it will be merged in. in
|
# because everything was created separately it will be merged in. in
|
||||||
# actual use we use a full sync to ensure initial a common starting point.
|
# actual use we use a full sync to ensure initial a common starting point.
|
||||||
|
@ -119,7 +124,9 @@ def test_facts():
|
||||||
assert client.sync() == "success"
|
assert client.sync() == "success"
|
||||||
assert deck2.getFact(fid)['Front'] == "abc"
|
assert deck2.getFact(fid)['Front'] == "abc"
|
||||||
# deletions too
|
# deletions too
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in a new issue