tahoe_fuse: system test: Populate a testdir with files and empty children directories, then test the fuse interface for proper listings and size metadata.

This commit is contained in:
nejucomo 2008-01-30 02:59:43 -07:00
parent 7240021d1c
commit 28552e5967

View File

@ -260,8 +260,43 @@ class SystemTest (object):
def test_empty_directory_listing(self, testcap, testdir):
listing = os.listdir(testdir)
if listing:
raise self.TestFailure('Expected empty directory, found: %r' % (listing,))
raise self.TestFailure('Expected empty directory, found: %r', listing)
def test_directory_listing(self, testcap, testdir):
names = []
filesizes = {}
for i in range(3):
fname = 'file_%d' % (i,)
names.append(fname)
body = 'Hello World #%d!' % (i,)
filesizes[fname] = len(body)
cap = self.webapi_call('PUT', '/uri', body)
self.attach_node(testcap, cap, fname)
dname = 'dir_%d' % (i,)
names.append(dname)
cap = self.create_dirnode()
self.attach_node(testcap, cap, dname)
names.sort()
listing = os.listdir(testdir)
listing.sort()
if listing != names:
tmpl = 'Expected directory list containing %r but fuse gave %r'
raise self.TestFailure(tmpl, names, listing)
for file, size in filesizes.items():
st = os.stat(os.path.join(testdir, file))
if st.st_size != size:
tmpl = 'Expected %r size of %r but fuse returned %r'
raise self.TestFailure(tmpl, file, size, st.st_size)
# Utilities:
def run_tahoe(self, *args):
realargs = ('tahoe',) + args