mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-26 05:49:44 +00:00
integration test fixups
This commit is contained in:
parent
fbc142d346
commit
41e6ec0fff
@ -176,11 +176,13 @@ def test_bob_creates_alice_deletes_bob_restores(magic_folder):
|
|||||||
"bob wrote this"
|
"bob wrote this"
|
||||||
)
|
)
|
||||||
|
|
||||||
# alice deletes it (so bob should as well
|
# alice deletes it (so bob should as well .. but keep a backup)
|
||||||
unlink(join(alice_dir, "boom"))
|
unlink(join(alice_dir, "boom"))
|
||||||
util.await_file_vanishes(join(bob_dir, "boom"))
|
util.await_file_vanishes(join(bob_dir, "boom"))
|
||||||
|
assert exists(join(bob_dir, "boom.backup"))
|
||||||
|
|
||||||
# bob restore it, with new contents
|
# bob restore it, with new contents
|
||||||
|
unlink(join(bob_dir, "boom.backup"))
|
||||||
with open(join(bob_dir, "boom"), "w") as f:
|
with open(join(bob_dir, "boom"), "w") as f:
|
||||||
f.write("bob wrote this again, because reasons")
|
f.write("bob wrote this again, because reasons")
|
||||||
|
|
||||||
@ -207,7 +209,7 @@ def test_bob_creates_alice_deletes_alice_restores(magic_folder):
|
|||||||
"bob wrote this"
|
"bob wrote this"
|
||||||
)
|
)
|
||||||
|
|
||||||
# alice deletes it (so bob should as well
|
# alice deletes it (so bob should as well)
|
||||||
unlink(join(alice_dir, "boom2"))
|
unlink(join(alice_dir, "boom2"))
|
||||||
util.await_file_vanishes(join(bob_dir, "boom2"))
|
util.await_file_vanishes(join(bob_dir, "boom2"))
|
||||||
|
|
||||||
@ -215,6 +217,12 @@ def test_bob_creates_alice_deletes_alice_restores(magic_folder):
|
|||||||
with open(join(alice_dir, "boom2"), "w") as f:
|
with open(join(alice_dir, "boom2"), "w") as f:
|
||||||
f.write("alice re-wrote this again, because reasons")
|
f.write("alice re-wrote this again, because reasons")
|
||||||
|
|
||||||
|
util.await_file_contents(
|
||||||
|
join(bob_dir, "boom2"),
|
||||||
|
"alice re-wrote this again, because reasons"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_bob_conflicts_with_alice_fresh(magic_folder):
|
def test_bob_conflicts_with_alice_fresh(magic_folder):
|
||||||
# both alice and bob make a file at "the same time".
|
# both alice and bob make a file at "the same time".
|
||||||
@ -270,22 +278,16 @@ def test_bob_conflicts_with_alice_preexisting(magic_folder):
|
|||||||
join(bob_dir, 'beta.conflict'),
|
join(bob_dir, 'beta.conflict'),
|
||||||
join(alice_dir, 'beta.conflict'),
|
join(alice_dir, 'beta.conflict'),
|
||||||
]
|
]
|
||||||
found = util.await_files_exist(acceptable, await_all=True)
|
found = util.await_files_exist(acceptable)
|
||||||
|
|
||||||
assert len(found) == 2, "both should have gotten a conflict"
|
assert len(found) >= 1, "should have found at least one conflict"
|
||||||
|
|
||||||
assert open(join(bob_dir, 'beta'), 'r').read() == "this is bob's beta\n"
|
assert open(join(bob_dir, 'beta'), 'r').read() == "this is bob's beta\n"
|
||||||
assert open(join(bob_dir, 'beta.conflict'), 'r').read() == "this is alice's beta\n"
|
|
||||||
assert open(join(alice_dir, 'beta'), 'r').read() == "this is alice's beta\n"
|
assert open(join(alice_dir, 'beta'), 'r').read() == "this is alice's beta\n"
|
||||||
if exists(join(alice_dir, 'beta.conflict')):
|
|
||||||
assert open(join(alice_dir, 'beta.conflict'), 'r').read() == "this is bob's beta\n"
|
|
||||||
|
|
||||||
assert exists(acceptable[1])
|
|
||||||
assert open(join(alice_dir, 'beta'), 'r').read() == "this is alice's beta\n"
|
|
||||||
assert open(join(alice_dir, 'beta.conflict'), 'r').read() == "this is bob's beta\n"
|
|
||||||
assert open(join(bob_dir, 'beta'), 'r').read() == "this is bob's beta\n"
|
|
||||||
if exists(join(bob_dir, 'beta.conflict')):
|
if exists(join(bob_dir, 'beta.conflict')):
|
||||||
assert open(join(bob_dir, 'beta.conflict'), 'r').read() == "this is alice's beta\n"
|
assert open(join(bob_dir, 'beta.conflict'), 'r').read() == "this is alice's beta\n"
|
||||||
|
if exists(join(alice_dir, 'beta.conflict')):
|
||||||
|
assert open(join(alice_dir, 'beta.conflict'), 'r').read() == "this is bob's beta\n"
|
||||||
|
|
||||||
|
|
||||||
@pytest.inlineCallbacks
|
@pytest.inlineCallbacks
|
||||||
|
@ -257,7 +257,9 @@ def await_files_exist(paths, timeout=15, await_all=False):
|
|||||||
if found:
|
if found:
|
||||||
return found
|
return found
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
raise Exception("Didn't find any of {} after {}s".format(', '.join(paths), timeout))
|
if await_all:
|
||||||
|
raise Exception("Didn't find {} after {}s".format(' and '.join(paths), timeout))
|
||||||
|
raise Exception("Didn't find {} after {}s".format(' or '.join(paths), timeout))
|
||||||
|
|
||||||
|
|
||||||
def await_file_vanishes(path, timeout=10):
|
def await_file_vanishes(path, timeout=10):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user