mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +00:00
webish: modify JSON to match zooko's proposed API changes in #118
This commit is contained in:
parent
0c22044f7e
commit
3e1c417f81
@ -268,17 +268,18 @@ class WebMixin(object):
|
||||
self.failUnless(isinstance(data, list))
|
||||
self.failUnlessEqual(data[0], "filenode")
|
||||
self.failUnless(isinstance(data[1], dict))
|
||||
self.failUnlessEqual(data[1]["mutable"], False)
|
||||
self.failIf("rw_uri" in data[1]) # immutable
|
||||
self.failUnlessEqual(data[1]["ro_uri"], self._bar_txt_uri)
|
||||
self.failUnlessEqual(data[1]["size"], 123)
|
||||
self.failUnlessEqual(data[1]["uri"], self._bar_txt_uri)
|
||||
|
||||
def failUnlessIsFooJSON(self, res):
|
||||
data = self.worlds_cheapest_json_decoder(res)
|
||||
self.failUnless(isinstance(data, list))
|
||||
self.failUnlessEqual(data[0], "dirnode")
|
||||
self.failUnless(isinstance(data[1], dict))
|
||||
self.failUnlessEqual(data[1]["mutable"], True)
|
||||
self.failUnlessEqual(data[1]["uri"], self._foo_uri)
|
||||
self.failUnless("rw_uri" in data[1]) # mutable
|
||||
self.failUnlessEqual(data[1]["rw_uri"], self._foo_uri)
|
||||
self.failUnlessEqual(data[1]["ro_uri"], self._foo_readonly_uri)
|
||||
kidnames = sorted(data[1]["children"].keys())
|
||||
self.failUnlessEqual(kidnames,
|
||||
["bar.txt", "blockingfile", "empty", "sub"])
|
||||
@ -286,7 +287,7 @@ class WebMixin(object):
|
||||
self.failUnlessEqual(kids["sub"][0], "dirnode")
|
||||
self.failUnlessEqual(kids["bar.txt"][0], "filenode")
|
||||
self.failUnlessEqual(kids["bar.txt"][1]["size"], 123)
|
||||
self.failUnlessEqual(kids["bar.txt"][1]["uri"], self._bar_txt_uri)
|
||||
self.failUnlessEqual(kids["bar.txt"][1]["ro_uri"], self._bar_txt_uri)
|
||||
|
||||
def GET(self, urlpath, followRedirect=False):
|
||||
url = self.webish_url + urlpath
|
||||
|
@ -398,8 +398,7 @@ class FileJSONMetadata(rend.Page):
|
||||
def renderNode(self, filenode):
|
||||
file_uri = filenode.get_uri()
|
||||
data = ("filenode",
|
||||
{'mutable': False,
|
||||
'uri': file_uri,
|
||||
{'ro_uri': file_uri,
|
||||
'size': filenode.get_size(),
|
||||
})
|
||||
return simplejson.dumps(data, indent=1)
|
||||
@ -488,22 +487,22 @@ class DirectoryJSONMetadata(rend.Page):
|
||||
if IFileNode.providedBy(childnode):
|
||||
kiduri = childnode.get_uri()
|
||||
kiddata = ("filenode",
|
||||
{'mutable': False,
|
||||
'uri': kiduri,
|
||||
{'ro_uri': kiduri,
|
||||
'size': childnode.get_size(),
|
||||
})
|
||||
else:
|
||||
assert IDirectoryNode.providedBy(childnode)
|
||||
kiduri = childnode.get_uri()
|
||||
kiddata = ("dirnode",
|
||||
{'mutable': childnode.is_mutable(),
|
||||
'uri': kiduri,
|
||||
{'ro_uri': childnode.get_immutable_uri(),
|
||||
})
|
||||
if childnode.is_mutable():
|
||||
kiddata[1]['rw_uri'] = childnode.get_uri()
|
||||
kids[name] = kiddata
|
||||
contents = { 'children': kids,
|
||||
'mutable': node.is_mutable(),
|
||||
'uri': node.get_uri(),
|
||||
'ro_uri': node.get_immutable_uri(),
|
||||
}
|
||||
if node.is_mutable():
|
||||
contents['rw_uri'] = node.get_uri()
|
||||
data = ("dirnode", contents)
|
||||
return simplejson.dumps(data, indent=1)
|
||||
d.addCallback(_got)
|
||||
|
Loading…
Reference in New Issue
Block a user