mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 03:06:33 +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.failUnless(isinstance(data, list))
|
||||||
self.failUnlessEqual(data[0], "filenode")
|
self.failUnlessEqual(data[0], "filenode")
|
||||||
self.failUnless(isinstance(data[1], dict))
|
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]["size"], 123)
|
||||||
self.failUnlessEqual(data[1]["uri"], self._bar_txt_uri)
|
|
||||||
|
|
||||||
def failUnlessIsFooJSON(self, res):
|
def failUnlessIsFooJSON(self, res):
|
||||||
data = self.worlds_cheapest_json_decoder(res)
|
data = self.worlds_cheapest_json_decoder(res)
|
||||||
self.failUnless(isinstance(data, list))
|
self.failUnless(isinstance(data, list))
|
||||||
self.failUnlessEqual(data[0], "dirnode")
|
self.failUnlessEqual(data[0], "dirnode")
|
||||||
self.failUnless(isinstance(data[1], dict))
|
self.failUnless(isinstance(data[1], dict))
|
||||||
self.failUnlessEqual(data[1]["mutable"], True)
|
self.failUnless("rw_uri" in data[1]) # mutable
|
||||||
self.failUnlessEqual(data[1]["uri"], self._foo_uri)
|
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())
|
kidnames = sorted(data[1]["children"].keys())
|
||||||
self.failUnlessEqual(kidnames,
|
self.failUnlessEqual(kidnames,
|
||||||
["bar.txt", "blockingfile", "empty", "sub"])
|
["bar.txt", "blockingfile", "empty", "sub"])
|
||||||
@ -286,7 +287,7 @@ class WebMixin(object):
|
|||||||
self.failUnlessEqual(kids["sub"][0], "dirnode")
|
self.failUnlessEqual(kids["sub"][0], "dirnode")
|
||||||
self.failUnlessEqual(kids["bar.txt"][0], "filenode")
|
self.failUnlessEqual(kids["bar.txt"][0], "filenode")
|
||||||
self.failUnlessEqual(kids["bar.txt"][1]["size"], 123)
|
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):
|
def GET(self, urlpath, followRedirect=False):
|
||||||
url = self.webish_url + urlpath
|
url = self.webish_url + urlpath
|
||||||
|
@ -398,8 +398,7 @@ class FileJSONMetadata(rend.Page):
|
|||||||
def renderNode(self, filenode):
|
def renderNode(self, filenode):
|
||||||
file_uri = filenode.get_uri()
|
file_uri = filenode.get_uri()
|
||||||
data = ("filenode",
|
data = ("filenode",
|
||||||
{'mutable': False,
|
{'ro_uri': file_uri,
|
||||||
'uri': file_uri,
|
|
||||||
'size': filenode.get_size(),
|
'size': filenode.get_size(),
|
||||||
})
|
})
|
||||||
return simplejson.dumps(data, indent=1)
|
return simplejson.dumps(data, indent=1)
|
||||||
@ -488,22 +487,22 @@ class DirectoryJSONMetadata(rend.Page):
|
|||||||
if IFileNode.providedBy(childnode):
|
if IFileNode.providedBy(childnode):
|
||||||
kiduri = childnode.get_uri()
|
kiduri = childnode.get_uri()
|
||||||
kiddata = ("filenode",
|
kiddata = ("filenode",
|
||||||
{'mutable': False,
|
{'ro_uri': kiduri,
|
||||||
'uri': kiduri,
|
|
||||||
'size': childnode.get_size(),
|
'size': childnode.get_size(),
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
assert IDirectoryNode.providedBy(childnode)
|
assert IDirectoryNode.providedBy(childnode)
|
||||||
kiduri = childnode.get_uri()
|
|
||||||
kiddata = ("dirnode",
|
kiddata = ("dirnode",
|
||||||
{'mutable': childnode.is_mutable(),
|
{'ro_uri': childnode.get_immutable_uri(),
|
||||||
'uri': kiduri,
|
|
||||||
})
|
})
|
||||||
|
if childnode.is_mutable():
|
||||||
|
kiddata[1]['rw_uri'] = childnode.get_uri()
|
||||||
kids[name] = kiddata
|
kids[name] = kiddata
|
||||||
contents = { 'children': kids,
|
contents = { 'children': kids,
|
||||||
'mutable': node.is_mutable(),
|
'ro_uri': node.get_immutable_uri(),
|
||||||
'uri': node.get_uri(),
|
|
||||||
}
|
}
|
||||||
|
if node.is_mutable():
|
||||||
|
contents['rw_uri'] = node.get_uri()
|
||||||
data = ("dirnode", contents)
|
data = ("dirnode", contents)
|
||||||
return simplejson.dumps(data, indent=1)
|
return simplejson.dumps(data, indent=1)
|
||||||
d.addCallback(_got)
|
d.addCallback(_got)
|
||||||
|
Loading…
Reference in New Issue
Block a user