]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_web.py: add coverage for directory listings that include mutable files
authorBrian Warner <warner@allmydata.com>
Wed, 5 Dec 2007 06:57:40 +0000 (23:57 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 5 Dec 2007 06:57:40 +0000 (23:57 -0700)
src/allmydata/test/common.py
src/allmydata/test/test_web.py
src/allmydata/webish.py

index eaeadb0f18d3ac9b67aaf9bbe307623fa31b4547..80a0dbb23c5b6c6f37f9383020e055a5454ece84 100644 (file)
@@ -92,6 +92,8 @@ class FakeMutableFileNode:
         return defer.succeed(self.all_contents[self.storage_index])
     def get_writekey(self):
         return "\x00"*16
+    def get_size(self):
+        return "?" # TODO: see mutable.MutableFileNode.get_size
 
     def replace(self, new_contents, wait_for_numpeers=None):
         assert not self.is_readonly()
index ca7afad7a403e9be61e04fb1f0fee821902f1d6d..f051ee0455f84a86322ffe95a5d430305251a695 100644 (file)
@@ -941,6 +941,17 @@ class Web(WebMixin, unittest.TestCase):
             self.failUnlessEqual(self._mutable_uri, newnode.get_uri())
         d.addCallback(_got3)
 
+        # finally list the directory, since mutable files are displayed
+        # differently
+
+        d.addCallback(lambda res:
+                      self.GET(self.public_url + "/foo",
+                               followRedirect=True))
+        def _check_page(res):
+            # TODO: assert something about the contents
+            pass
+        d.addCallback(_check_page)
+
         return d
 
     def test_POST_upload_replace(self):
index 4e6c0bad39a340fa16d821620f30f9339056c26c..c20403a4cd84e3eeaf6976c74c9befc04923c76e 100644 (file)
@@ -185,7 +185,7 @@ class Directory(rend.Page):
                 or IDirectoryNode.providedBy(target)
                 or IMutableFileNode.providedBy(target)), target
 
-        if IFileNode.providedBy(target):
+        if IMutableFileNode.providedBy(target):
             # file
 
             # add the filename to the uri_link url
@@ -199,14 +199,14 @@ class Directory(rend.Page):
 
             ctx.fillSlots("filename",
                           T.a(href=dlurl)[html.escape(name)])
-            ctx.fillSlots("type", "FILE")
+            ctx.fillSlots("type", "SSK")
 
-            ctx.fillSlots("size", target.get_size())
+            ctx.fillSlots("size", "?")
 
             text_plain_link = uri_link + "?filename=foo.txt"
             text_plain_tag = T.a(href=text_plain_link)["text/plain"]
 
-        elif IMutableFileNode.providedBy(target):
+        elif IFileNode.providedBy(target):
             # file
 
             # add the filename to the uri_link url
@@ -220,14 +220,13 @@ class Directory(rend.Page):
 
             ctx.fillSlots("filename",
                           T.a(href=dlurl)[html.escape(name)])
-            ctx.fillSlots("type", "SSK")
+            ctx.fillSlots("type", "FILE")
 
-            ctx.fillSlots("size", "?")
+            ctx.fillSlots("size", target.get_size())
 
             text_plain_link = uri_link + "?filename=foo.txt"
             text_plain_tag = T.a(href=text_plain_link)["text/plain"]
 
-
         elif IDirectoryNode.providedBy(target):
             # directory
             subdir_url = urllib.quote(name)