speed up two tests

the regular test run is now faster than the old parallel one was
This commit is contained in:
Damien Elmes 2020-01-03 09:04:41 +10:00
parent 9abeeac73a
commit 0f4f3ab2c1
2 changed files with 14 additions and 5 deletions

View file

@ -88,6 +88,10 @@ def test_changes():
def removed():
return d.media.db.execute("select fname from media where csum is null")
def advanceTime():
d.media.db.execute("update media set mtime=mtime-1")
d.media.db.execute("update meta set dirMod = dirMod - 1")
assert not list(added())
assert not list(removed())
# add a file
@ -95,27 +99,26 @@ def test_changes():
path = os.path.join(dir, "foo.jpg")
with open(path, "w") as f:
f.write("hello")
time.sleep(1)
path = d.media.addFile(path)
# should have been logged
d.media.findChanges()
assert list(added())
assert not list(removed())
# if we modify it, the cache won't notice
time.sleep(1)
advanceTime()
with open(path, "w") as f:
f.write("world")
assert len(list(added())) == 1
assert not list(removed())
# but if we add another file, it will
time.sleep(1)
advanceTime()
with open(path + "2", "w") as f:
f.write("yo")
d.media.findChanges()
assert len(list(added())) == 2
assert not list(removed())
# deletions should get noticed too
time.sleep(1)
advanceTime()
os.unlink(path + "2")
d.media.findChanges()
assert len(list(added())) == 1

View file

@ -943,9 +943,15 @@ def test_timing():
c = d.sched.getCard()
assert c.queue == 2
# but if we wait for a second, the failed card should come back
time.sleep(1)
orig_time = time.time
def adjusted_time():
return orig_time() + 1
time.time = adjusted_time
c = d.sched.getCard()
assert c.queue == 1
time.time = orig_time
def test_collapse():