]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Additional test for DIR2-LIT directories in test_web.py, fixed version (#948)
authordavid-sarah <david-sarah@jacaranda.org>
Thu, 25 Feb 2010 04:18:24 +0000 (20:18 -0800)
committerdavid-sarah <david-sarah@jacaranda.org>
Thu, 25 Feb 2010 04:18:24 +0000 (20:18 -0800)
src/allmydata/test/common.py
src/allmydata/test/test_web.py

index 6c37f8c6655bbf9bfab57d25a4d74679fbf35e3e..f1bfe3dcb6cdc9424505ebe5d30161c64db6a4a4 100644 (file)
@@ -113,6 +113,8 @@ class FakeCHKFileNode:
         pass
 
     def get_size(self):
+        if isinstance(self.my_uri, uri.LiteralFileURI):
+            return self.my_uri.get_size()
         try:
             data = self.all_contents[self.my_uri.to_string()]
         except KeyError, le:
@@ -131,9 +133,12 @@ class FakeCHKFileNode:
         return d
 
     def _read(self, ignored, consumer, offset, size):
-        if self.my_uri.to_string() not in self.all_contents:
-            raise NotEnoughSharesError(None, 0, 3)
-        data = self.all_contents[self.my_uri.to_string()]
+        if isinstance(self.my_uri, uri.LiteralFileURI):
+            data = self.my_uri.data
+        else:
+            if self.my_uri.to_string() not in self.all_contents:
+                raise NotEnoughSharesError(None, 0, 3)
+            data = self.all_contents[self.my_uri.to_string()]
         start = offset
         if size is not None:
             end = offset + size
@@ -288,9 +293,12 @@ class FakeMutableFileNode:
         return d
 
     def download_best_version(self):
+        if isinstance(self.my_uri, uri.LiteralFileURI):
+            return defer.succeed(self.my_uri.data)
         if self.storage_index not in self.all_contents:
             return defer.fail(NotEnoughSharesError(None, 0, 3))
         return defer.succeed(self.all_contents[self.storage_index])
+
     def overwrite(self, new_contents):
         if len(new_contents) > self.MUTABLE_SIZELIMIT:
             raise FileTooLargeError("SDMF is limited to one segment, and "
@@ -464,7 +472,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
             if self.stats_gatherer_furl:
                 write("stats_gatherer.furl", self.stats_gatherer_furl)
 
-        # give subclasses a chance to append liens to the node's tahoe.cfg
+        # give subclasses a chance to append lines to the node's tahoe.cfg
         # files before they are launched.
         self._set_up_nodes_extra_config()
 
index f9e375135d8d17238d8f4b952397cb25edf03354..b1485981a7e73a0076b31147278d3fdf8b4dff83 100644 (file)
@@ -994,6 +994,15 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
             self.failUnless(MKDIR_BUTTON_RE.search(res), res)
         d.addCallback(_check4)
 
+        # and at a literal directory
+        tiny_litdir_uri = "URI:DIR2-LIT:gqytunj2onug64tufqzdcosvkjetutcjkq5gw4tvm5vwszdgnz5hgyzufqydulbshj5x2lbm" # contains one child which is itself also LIT
+        d.addCallback(lambda res:
+                      self.GET("/uri/" + tiny_litdir_uri + "/", followRedirect=True))
+        def _check5(res):
+            self.failUnless('(immutable)' in res, res)
+            self.failUnless(re.search('<td>FILE</td>'
+                                      r'\s+<td><a href="[\.\/]+/file/URI%3ALIT%3Akrugkidfnzsc4/@@named=/short">short</a></td>', res), res)
+        d.addCallback(_check5)
         return d
 
     def test_GET_DIRURL_badtype(self):