children = d['children']
elif nodetype == "filenode":
childname = path.split("/")[-1]
- children = {childname: d}
+ children = {childname: (nodetype, d)}
childnames = sorted(children.keys())
now = time.time()
d.addCallback(_check3)
d.addCallback(lambda ign: self.do_cli("ls", "0share"))
d.addCallback(_check3)
+ def _check4((rc, out, err)):
+ self.failUnlessEqual(rc, 0)
+ self.failUnlessIn("good", out)
+ d.addCallback(lambda ign: self.do_cli("ls", "good"))
+ d.addCallback(_check4)
return d
class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
d.addBoth(self.should404, "test_DELETE_FILEURL_missing2")
return d
+ def failUnlessHasBarDotTxtMetadata(self, res):
+ data = simplejson.loads(res)
+ self.failUnless(isinstance(data, list))
+ self.failUnless(data[1].has_key("metadata"))
+ self.failUnless(data[1]["metadata"].has_key("ctime"))
+ self.failUnless(data[1]["metadata"].has_key("mtime"))
+ self.failUnlessEqual(data[1]["metadata"]["ctime"],
+ self._bar_txt_metadata["ctime"])
+
def test_GET_FILEURL_json(self):
# twisted.web.http.parse_qs ignores any query args without an '=', so
# I can't do "GET /path?json", I have to do "GET /path/t=json"
# instead. This may make it tricky to emulate the S3 interface
# completely.
d = self.GET(self.public_url + "/foo/bar.txt?t=json")
- d.addCallback(self.failUnlessIsBarJSON)
+ def _check1(data):
+ self.failUnlessIsBarJSON(data)
+ self.failUnlessHasBarDotTxtMetadata(data)
+ return
+ d.addCallback(_check1)
return d
def test_GET_FILEURL_json_missing(self):
d.addCallback(lambda dn: FileDownloader(dn, filename))
return d
if t == "json":
- return FileJSONMetadata(ctx, self.node)
+ if self.parentnode and self.name:
+ d = self.parentnode.get_metadata_for(self.name)
+ else:
+ d = defer.succeed(None)
+ d.addCallback(lambda md: FileJSONMetadata(ctx, self.node, md))
+ return d
if t == "info":
return MoreInfo(self.node)
if t == "uri":
return req.deferred
-def FileJSONMetadata(ctx, filenode):
+def FileJSONMetadata(ctx, filenode, edge_metadata=None):
if filenode.is_readonly():
rw_uri = None
ro_uri = filenode.get_uri()
if verifycap:
data[1]['verify_uri'] = verifycap.to_string()
data[1]['mutable'] = filenode.is_mutable()
+ if edge_metadata:
+ data[1]["metadata"] = edge_metadata
return text_plain(simplejson.dumps(data, indent=1) + "\n", ctx)
def FileURI(ctx, filenode):