Commit eb3a732f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 04e8a863
...@@ -27,6 +27,7 @@ from pytest import raises ...@@ -27,6 +27,7 @@ from pytest import raises
testdb = None testdb = None
testzurl = None testzurl = None
testmntpt = None
def setup_module(): def setup_module():
global testdb, testzurl, testmntpt global testdb, testzurl, testmntpt
testdb = getTestDB() testdb = getTestDB()
...@@ -45,7 +46,7 @@ def teardown_module(): ...@@ -45,7 +46,7 @@ def teardown_module():
def setup_function(f): def setup_function(f):
assert not os.path.exists(testmntpt) assert not os.path.exists(testmntpt)
# make sure we unmount wcfs after every function # make sure we unmount wcfs after every test
def teardown_function(f): def teardown_function(f):
mounted = not subprocess.call(["mountpoint", "-q", testmntpt]) mounted = not subprocess.call(["mountpoint", "-q", testmntpt])
if mounted: if mounted:
...@@ -59,24 +60,38 @@ def readfile(path): ...@@ -59,24 +60,38 @@ def readfile(path):
with open(path) as f: with open(path) as f:
return f.read() return f.read()
# check that zurl does not change from one open to another storage open.
def test_zurlstable():
for i in range(10):
zstor = testdb.getZODBStorage()
zurl = wcfs._zstor_2zurl(zstor)
zstor.close()
assert zurl == testzurl
def test_join(): def test_join():
zstor = testdb.getZODBStorage() zurl = testzurl
zurl = wcfs._zstor_2zurl(zstor)
with raises(RuntimeError, match="wcfs: join .*: server not started"): with raises(RuntimeError, match="wcfs: join .*: server not started"):
wcfs.join(zurl, autostart=False) wcfs.join(zurl, autostart=False)
wc = wcfs._start(zurl) wc = wcfs._start(zurl)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl assert readfile(wc.mountpoint + "/.wcfs") == zurl
wc2 = wcfs.join(zurl, autostart=False) wc2 = wcfs.join(zurl, autostart=False)
assert wc2.mountpoint == wc.mountpoint assert wc2.mountpoint == wc.mountpoint
wc.close() wc.close()
wc2.close() wc2.close()
zstor.close()
def test_join_autostart(): def test_join_autostart():
# XXX zurl = testzurl
pass with raises(RuntimeError, match="wcfs: join .*: server not started"):
wcfs.join(zurl, autostart=False)
wc = wcfs.join(zurl, autostart=True)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl
wc.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment