mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
fix media unittest, turn of sync during upgrade
This commit is contained in:
parent
6356e6f06b
commit
0ef3fe5d75
2 changed files with 11 additions and 9 deletions
|
@ -132,6 +132,7 @@ and c.ordinal != cm.ordinal"""):
|
||||||
# speed up the upgrade
|
# speed up the upgrade
|
||||||
db.execute("pragma temp_store = memory")
|
db.execute("pragma temp_store = memory")
|
||||||
db.execute("pragma cache_size = 10000")
|
db.execute("pragma cache_size = 10000")
|
||||||
|
db.execute("pragma synchronous = off")
|
||||||
# these weren't always correctly set
|
# these weren't always correctly set
|
||||||
db.execute("pragma page_size = 4096")
|
db.execute("pragma page_size = 4096")
|
||||||
db.execute("pragma legacy_file_format = 0")
|
db.execute("pragma legacy_file_format = 0")
|
||||||
|
|
|
@ -63,7 +63,9 @@ def test_deckIntegration():
|
||||||
def test_changes():
|
def test_changes():
|
||||||
d = getEmptyDeck()
|
d = getEmptyDeck()
|
||||||
assert d.media._changed()
|
assert d.media._changed()
|
||||||
assert not list(d.media.added())
|
def added():
|
||||||
|
return d.media.db.execute("select fname from log where type = 0")
|
||||||
|
assert not list(added())
|
||||||
assert not list(d.media.removed())
|
assert not list(d.media.removed())
|
||||||
# add a file
|
# add a file
|
||||||
dir = tempfile.mkdtemp(prefix="anki")
|
dir = tempfile.mkdtemp(prefix="anki")
|
||||||
|
@ -72,24 +74,23 @@ def test_changes():
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
path = d.media.addFile(path)
|
path = d.media.addFile(path)
|
||||||
# should have been logged
|
# should have been logged
|
||||||
assert list(d.media.added())
|
d.media.findChanges()
|
||||||
|
assert list(added())
|
||||||
assert not list(d.media.removed())
|
assert not list(d.media.removed())
|
||||||
# if we modify it, the cache won't notice
|
# if we modify it, the cache won't notice
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
open(path, "w").write("world")
|
open(path, "w").write("world")
|
||||||
assert len(list(d.media.added())) == 1
|
assert len(list(added())) == 1
|
||||||
assert not list(d.media.removed())
|
assert not list(d.media.removed())
|
||||||
# but if we add another file, it will
|
# but if we add another file, it will
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
open(path+"2", "w").write("yo")
|
open(path+"2", "w").write("yo")
|
||||||
assert len(list(d.media.added())) == 2
|
d.media.findChanges()
|
||||||
|
assert len(list(added())) == 2
|
||||||
assert not list(d.media.removed())
|
assert not list(d.media.removed())
|
||||||
# deletions should get noticed too
|
# deletions should get noticed too
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
os.unlink(path+"2")
|
os.unlink(path+"2")
|
||||||
assert len(list(d.media.added())) == 1
|
d.media.findChanges()
|
||||||
|
assert len(list(added())) == 1
|
||||||
assert len(list(d.media.removed())) == 1
|
assert len(list(d.media.removed())) == 1
|
||||||
# after a sync completes, it clears the log
|
|
||||||
d.media.clearLog()
|
|
||||||
assert len(list(d.media.added())) == 0
|
|
||||||
assert len(list(d.media.removed())) == 0
|
|
||||||
|
|
Loading…
Reference in a new issue