+ # The SDMF size limit is no longer in place, so we should be
+ # able to upload mutable files that are as large as we want them
+ # to be.
+ d = self.POST("/uri", t="upload", mutable="true",
+ file=("new.txt", "b" * (self.s.MUTABLE_SIZELIMIT + 1)))
+ return d
+
+
+ def test_POST_upload_mutable_type_unlinked(self):
+ d = self.POST("/uri?t=upload&mutable=true&mutable-type=sdmf",
+ file=("sdmf.txt", self.NEWFILE_CONTENTS * 300000))
+ d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % filecap))
+ def _got_json(json, version):
+ data = simplejson.loads(json)
+ data = data[1]
+
+ self.failUnlessIn("mutable-type", data)
+ self.failUnlessEqual(data['mutable-type'], version)
+ d.addCallback(_got_json, "sdmf")
+ d.addCallback(lambda ignored:
+ self.POST("/uri?t=upload&mutable=true&mutable-type=mdmf",
+ file=('mdmf.txt', self.NEWFILE_CONTENTS * 300000)))
+ def _got_filecap(filecap):
+ self.failUnless(filecap.startswith("URI:MDMF"))
+ return filecap
+ d.addCallback(_got_filecap)
+ d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % filecap))
+ d.addCallback(_got_json, "mdmf")
+ return d
+
+ def test_POST_upload_mutable_type_unlinked_bad_mutable_type(self):
+ return self.shouldHTTPError("test bad mutable type",
+ 400, "Bad Request", "Unknown type: foo",
+ self.POST,
+ "/uri?5=upload&mutable=true&mutable-type=foo",
+ file=("foo.txt", self.NEWFILE_CONTENTS * 300000))
+
+ def test_POST_upload_mutable_type(self):
+ d = self.POST(self.public_url + \
+ "/foo?t=upload&mutable=true&mutable-type=sdmf",
+ file=("sdmf.txt", self.NEWFILE_CONTENTS * 300000))
+ fn = self._foo_node
+ def _got_cap(filecap, filename):
+ filenameu = unicode(filename)
+ self.failUnlessURIMatchesRWChild(filecap, fn, filenameu)
+ return self.GET(self.public_url + "/foo/%s?t=json" % filename)
+ def _got_mdmf_cap(filecap):
+ self.failUnless(filecap.startswith("URI:MDMF"))
+ return filecap
+ d.addCallback(_got_cap, "sdmf.txt")
+ def _got_json(json, version):
+ data = simplejson.loads(json)
+ data = data[1]
+
+ self.failUnlessIn("mutable-type", data)
+ self.failUnlessEqual(data['mutable-type'], version)
+ d.addCallback(_got_json, "sdmf")
+ d.addCallback(lambda ignored:
+ self.POST(self.public_url + \
+ "/foo?t=upload&mutable=true&mutable-type=mdmf",
+ file=("mdmf.txt", self.NEWFILE_CONTENTS * 300000)))
+ d.addCallback(_got_mdmf_cap)
+ d.addCallback(_got_cap, "mdmf.txt")
+ d.addCallback(_got_json, "mdmf")