From: Brian Warner Date: Wed, 5 Dec 2007 06:57:40 +0000 (-0700) Subject: test_web.py: add coverage for directory listings that include mutable files X-Git-Url: https://git.rkrishnan.org/listings/pb1server.py?a=commitdiff_plain;h=53e865cf4985660512b7952ec74c51183b60f01a;p=tahoe-lafs%2Ftahoe-lafs.git test_web.py: add coverage for directory listings that include mutable files --- diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index eaeadb0f..80a0dbb2 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -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() diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index ca7afad7..f051ee04 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -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): diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 4e6c0bad..c20403a4 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -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)