From af9e1f62381f47c008ffd1052d6dbd09bfacb1fa Mon Sep 17 00:00:00 2001
From: robk-tahoe <robk-tahoe@allmydata.com>
Date: Fri, 3 Oct 2008 10:20:44 -0700
Subject: [PATCH] fuse/runtests: add a very simple 'write' test

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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/contrib/fuse/runtests.py b/contrib/fuse/runtests.py
index 059d0818..0a25a40e 100644
--- a/contrib/fuse/runtests.py
+++ b/contrib/fuse/runtests.py
@@ -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):
-- 
2.45.2