]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fuse/runtests: add a very simple 'write' test
authorrobk-tahoe <robk-tahoe@allmydata.com>
Fri, 3 Oct 2008 17:20:44 +0000 (10:20 -0700)
committerrobk-tahoe <robk-tahoe@allmydata.com>
Fri, 3 Oct 2008 17:20:44 +0000 (10:20 -0700)
this performs a very simple write through the fuse layer and confirms that
the file is stored correctly into the tahoe mesh.  ('simple' in the sense
that the entire file body fits trivially in a single write() operation,
disk block etc)

contrib/fuse/runtests.py

index 059d0818fbd899f68b0d84060b96465ddf056798..0a25a40e32f66c4bfe54b548715e76b753b32451 100644 (file)
@@ -426,6 +426,29 @@ class SystemTest (object):
             tmpl = 'Expected file contents %r but found %r'
             raise TestFailure(tmpl, body, found)
 
+    def get_file(self, dircap, path):
+        body = self.webapi_call('GET', '/uri/%s/%s' % (dircap, path))
+        return body
+
+    def test_write_small_file(self, testcap, testdir):
+        name = 'smallfile.txt'
+        body = 'this is a small file'
+
+        try:
+            path = os.path.join(testdir, name)
+            f = file(path, 'w')
+            f.write(body)
+            f.close()
+        except Exception, err:
+            tmpl = 'Could not write file contents at %r: %r'
+            raise TestFailure(tmpl, path, err)
+
+        uploaded_body = self.get_file(testcap, name)
+
+        if uploaded_body != body:
+            tmpl = 'Expected file contents %r but found %r'
+            raise TestFailure(tmpl, body, uploaded_body)
+
 
     # Utilities:
     def run_tahoe(self, *args):