From: Brian Warner Date: Thu, 13 Oct 2011 16:31:43 +0000 (-0700) Subject: webapi: use all-caps "SDMF"/"MDMF" acronyms in t=json response X-Git-Url: https://git.rkrishnan.org/nxhtml.html?a=commitdiff_plain;h=01b00dc7dca9108f4c6ac8d266020873475dce34;p=tahoe-lafs%2Ftahoe-lafs.git webapi: use all-caps "SDMF"/"MDMF" acronyms in t=json response docs: upcase examples of t=json output and format= input --- diff --git a/docs/frontends/webapi.rst b/docs/frontends/webapi.rst index 105db627..6365f441 100644 --- a/docs/frontends/webapi.rst +++ b/docs/frontends/webapi.rst @@ -379,8 +379,8 @@ Writing/Uploading A File immutable file, the "offset" parameter is not valid. When creating a new file, you can control the type of file created by - specifying a format= argument in the query string. format=mdmf creates an MDMF - mutable file. format=sdmf creates an SDMF mutable file. format=chk creates an + specifying a format= argument in the query string. format=MDMF creates an MDMF + mutable file. format=SDMF creates an SDMF mutable file. format=CHK creates an immutable file. The value of the format argument is case-insensitive. For compatibility with previous versions of Tahoe-LAFS, the webapi will also accept a mutable=true argument in the query string. If mutable=true is given, @@ -421,8 +421,8 @@ Creating A New Directory new code should use POST. This supports a format= argument in the query string. The format= - argument, if specified, controls the format of the directory. format=mdmf - indicates that the directory should be stored as an MDMF file; format=sdmf + argument, if specified, controls the format of the directory. format=MDMF + indicates that the directory should be stored as an MDMF file; format=SDMF indicates that the directory should be stored as an SDMF file. The value of the format= argument is case-insensitive. If no format= argument is given, the directory's format is determined by the default mutable file @@ -678,7 +678,7 @@ Getting Information About A File Or Directory (as JSON) "verify_uri": verify_uri, "size": bytes, "mutable": false, - "format": "chk" + "format": "CHK" } ] If it is a capability to a directory followed by a path from that directory @@ -692,7 +692,7 @@ Getting Information About A File Or Directory (as JSON) "verify_uri": verify_uri, "size": bytes, "mutable": false, - "format": "chk", + "format": "CHK", "metadata": { "ctime": 1202777696.7564139, "mtime": 1202777696.7564139, @@ -716,7 +716,7 @@ Getting Information About A File Or Directory (as JSON) "ro_uri": read_only_uri, "verify_uri": verify_uri, "mutable": true, - "format": "sdmf", + "format": "SDMF", "children": { "foo.txt": [ "filenode", { diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 123df201..6cc70b0f 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -1145,7 +1145,7 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase): def _check_mdmf_json(self, (rc, json, err)): self.failUnlessEqual(rc, 0) self.failUnlessEqual(err, "") - self.failUnlessIn('"format": "mdmf"', json) + self.failUnlessIn('"format": "MDMF"', json) # We also want a valid MDMF cap to be in the json. self.failUnlessIn("URI:MDMF", json) self.failUnlessIn("URI:MDMF-RO", json) @@ -1154,7 +1154,7 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase): def _check_sdmf_json(self, (rc, json, err)): self.failUnlessEqual(rc, 0) self.failUnlessEqual(err, "") - self.failUnlessIn('"format": "sdmf"', json) + self.failUnlessIn('"format": "SDMF"', json) # We also want to see the appropriate SDMF caps. self.failUnlessIn("URI:SSK", json) self.failUnlessIn("URI:SSK-RO", json) @@ -1618,8 +1618,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase): self.failUnlessIn(self._sdmf_uri, out) self.failUnlessIn(self._sdmf_readonly_uri, out) self.failUnlessIn(self._imm_uri, out) - self.failUnlessIn('"format": "sdmf"', out) - self.failUnlessIn('"format": "mdmf"', out) + self.failUnlessIn('"format": "SDMF"', out) + self.failUnlessIn('"format": "MDMF"', out) d.addCallback(_got_json) return d @@ -3318,7 +3318,7 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase): d2.addCallback(lambda ign: self.do_cli("ls", "--json", dirname)) d2.addCallback(_check, uri_prefix) d2.addCallback(lambda ign: self.do_cli("ls", "--json", self._filecap)) - d2.addCallback(_check, '"format": "%s"' % (mutable_type.lower(),)) + d2.addCallback(_check, '"format": "%s"' % (mutable_type.upper(),)) return d2 d.addCallback(_mkdir, "sdmf", "URI:DIR2", "tahoe:foo") @@ -3348,13 +3348,13 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase): d.addCallback(_stash_dircap) d.addCallback(lambda res: self.do_cli("ls", "--json", self._filecap)) - d.addCallback(_check, '"format": "sdmf"') + d.addCallback(_check, '"format": "SDMF"') d.addCallback(lambda res: self.do_cli("mkdir", "--mutable-type=mdmf")) d.addCallback(_check, "URI:DIR2-MDMF") d.addCallback(_stash_dircap) d.addCallback(lambda res: self.do_cli("ls", "--json", self._filecap)) - d.addCallback(_check, '"format": "mdmf"') + d.addCallback(_check, '"format": "MDMF"') return d def test_mkdir_bad_mutable_type(self): diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index ceb468b9..b2464a6a 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -1072,7 +1072,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi return filecap d.addCallback(_got_filecap) d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % filecap)) - d.addCallback(lambda json: self.failUnlessIn("mdmf", json)) + d.addCallback(lambda json: self.failUnlessIn("MDMF", json)) return d def test_PUT_NEWFILEURL_unlinked_sdmf(self): @@ -1080,7 +1080,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi d = self.PUT("/uri?format=sdmf", contents) d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % filecap)) - d.addCallback(lambda json: self.failUnlessIn("sdmf", json)) + d.addCallback(lambda json: self.failUnlessIn("SDMF", json)) return d def test_PUT_NEWFILEURL_unlinked_bad_format(self): @@ -1235,13 +1235,13 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi self.failUnlessIn("format", data) self.failUnlessEqual(data["format"], version) - d.addCallback(_got_json, "mdmf") + d.addCallback(_got_json, "MDMF") # Now make an SDMF file and check that it is reported correctly. d.addCallback(lambda ignored: self.PUT("/uri?format=sdmf", self.NEWFILE_CONTENTS * 300000)) d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % filecap)) - d.addCallback(_got_json, "sdmf") + d.addCallback(_got_json, "SDMF") return d def test_GET_FILEURL_json_mdmf(self): @@ -1430,11 +1430,11 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi mdmf_data = kids['mdmf.txt'][1] self.failUnlessIn("format", mdmf_data) - self.failUnlessEqual(mdmf_data["format"], "mdmf") + self.failUnlessEqual(mdmf_data["format"], "MDMF") sdmf_data = kids['sdmf.txt'][1] self.failUnlessIn("format", sdmf_data) - self.failUnlessEqual(sdmf_data["format"], "sdmf") + self.failUnlessEqual(sdmf_data["format"], "SDMF") d.addCallback(_got_json) return d @@ -2141,7 +2141,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi data = simplejson.loads(json) data = data[1] self.failUnlessIn("format", data) - self.failUnlessEqual(data["format"], format.lower()) + self.failUnlessEqual(data["format"], format.upper()) d.addCallback(_got_json) return d d = defer.succeed(None) @@ -2175,7 +2175,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi data = simplejson.loads(json) data = data[1] self.failUnlessIn("format", data) - self.failUnlessEqual(data["format"], format.lower()) + self.failUnlessEqual(data["format"], format.upper()) d.addCallback(_got_json) return d @@ -3468,7 +3468,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi data = simplejson.loads(json) data = data[1] self.failUnlessIn("format", data) - self.failUnlessEqual(data["format"], "mdmf") + self.failUnlessEqual(data["format"], "MDMF") self.failUnless(data['rw_uri'].startswith("URI:MDMF")) self.failUnless(data['ro_uri'].startswith("URI:MDMF")) d.addCallback(_got_json) @@ -3485,7 +3485,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi data = simplejson.loads(json) data = data[1] self.failUnlessIn("format", data) - self.failUnlessEqual(data["format"], "sdmf") + self.failUnlessEqual(data["format"], "SDMF") d.addCallback(_got_json) return d diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index 5c58c495..58fe7816 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -869,11 +869,11 @@ def DirectoryJSONMetadata(ctx, dirnode): mutable_type = childnode.get_version() assert mutable_type in (SDMF_VERSION, MDMF_VERSION) if mutable_type == MDMF_VERSION: - file_format = "mdmf" + file_format = "MDMF" else: - file_format = "sdmf" + file_format = "SDMF" else: - file_format = "chk" + file_format = "CHK" kiddata[1]['format'] = file_format elif IDirectoryNode.providedBy(childnode): diff --git a/src/allmydata/web/filenode.py b/src/allmydata/web/filenode.py index 89db41bf..28913170 100644 --- a/src/allmydata/web/filenode.py +++ b/src/allmydata/web/filenode.py @@ -514,11 +514,11 @@ def FileJSONMetadata(ctx, filenode, edge_metadata): mutable_type = filenode.get_version() assert mutable_type in (SDMF_VERSION, MDMF_VERSION) if mutable_type == MDMF_VERSION: - file_format = "mdmf" + file_format = "MDMF" else: - file_format = "sdmf" + file_format = "SDMF" else: - file_format = "chk" + file_format = "CHK" data[1]['format'] = file_format return text_plain(simplejson.dumps(data, indent=1) + "\n", ctx)