Mercurial > p > roundup > code
changeset 8180:d02ce1d14acd
feat: issue2551068 - Provide way to retrieve file/msg data via rest endpoint.
Use Allow header to change format of /binary_content endpoint. If
Allow header for endpoint is not application/json, it will be matched
against the mime type for the file. */*, text/* are supported and will
return the native mime type if present.
Changes:
move */* mime type from static dict of supported types. It was
hardcoded to return json only. Now it can return a matching
non-json mime type for the /binary_content endpoint.
Edited some errors to explicitly add */* mime type.
Cleanups to use ', ' separation in lists of valid mime types rather
than just space separated.
Remove ETag header when sending raw content. See issue 2551375 for
background.
Doc added to rest.txt.
Small format fix up (add dash) in CHANGES.txt.
Make passing an unset/None/False accept_mime_type to
format_dispatch_output a 500 error. This used to be the fallback
to produce a 406 error after all processing had happened. It
should no longer be possible to take that code path as all 406
errors (with valid accept_mime_types) are generated before
processing takes place.
Make format_dispatch_output handle output other than json/xml so it
can send back binary_content data.
Removed a spurious client.response_code = 400 that seems to not be
used.
Tests added for all code paths.
Database setup for tests msg and file entry. This required a file
upload test to change so it doesn't look for file1 as the link
returned by the upload. Download the link and verify the data
rather than verifying the link.
Multiple formatting changes to error messages to make all lists of
valid mime types ', ' an not just space separated.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 08 Dec 2024 17:22:33 -0500 |
| parents | 53afc3ffd4a2 |
| children | 0a6ca45c53b4 |
| files | CHANGES.txt doc/rest.txt roundup/rest.py test/rest_common.py |
| diffstat | 4 files changed, 492 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Sun Dec 08 09:11:53 2024 -0500 +++ b/CHANGES.txt Sun Dec 08 17:22:33 2024 -0500 @@ -47,7 +47,7 @@ - issue2551315 - Document use of RestfulInstance.max_response_row_size to limit data returned from rest request. -- issue2551330 Add an optional 'filter' function to the Permission +- issue2551330 - Add an optional 'filter' function to the Permission objects and the addPermission method. This is used to optimize search performance by not checking items returned from a database query one-by-one (using the check function) but instead offload the @@ -60,6 +60,11 @@ address. This logs the actual client address when roundup-server is run behind a reverse proxy. It also appends a + sign to the logged address/name. (John Rouillard) +- issue2551068 - Provide way to retrieve file/msg data via rest + endpoint. Raw file/msg data can be retrieved using the + /binary_content attribute and an Accept header to select the mime + type for the data (e.g. image/png for a png file). The existing html + interface method still works and is supported, but is legacy. 2024-07-13 2.4.0
--- a/doc/rest.txt Sun Dec 08 09:11:53 2024 -0500 +++ b/doc/rest.txt Sun Dec 08 17:22:33 2024 -0500 @@ -368,7 +368,7 @@ will force json or xml (if supported) output. If you use an extension it takes priority over any accept headers. Note the extension does not work for the ``/rest`` or ``/rest/data`` paths. In these cases it -returs a 404 error. Adding the header ``Accept: application/xml`` +returns a 404 error. Adding the header ``Accept: application/xml`` allows these paths to return xml data. The rest interface returns status 406 if you use an unrecognized @@ -378,6 +378,8 @@ Note: ``dicttoxml2.py`` is an updated version of ``dicttoxml.py``. If you are still using Python 2.7 or 3.6, you can use ``dicttoxml.py``. +Also the ``/binary_content`` attribute endpoint can be used to +retrieve raw file data in many formats. General Guidelines ------------------ @@ -906,6 +908,86 @@ } } +With Roundup 2.5 you can retrieve the data directly from the rest +interface using the ``Accept`` header value to select a structured (json +or optional xml) representation (as above) or a stream with just the +content data. + +Using the wildcard type ``*/*`` in the ``Accept`` header with the url +``.../binary_content`` will return the raw data and the recorded mime +type of the the data as the ``Content-Type``. Using ``*/*`` with +another end point will return ``json`` data. An ``Accept`` value of +``application/octet-stream`` matches any mime type and retrieves the +raw data as ``Content-Type: application/octet-stream``. + +To access the contents of a PNG image file (in file23), you use the +following link: +``https://.../demo/rest/data/file/23/binary_content``. To find out the +mime type, you can check this URL: +``https://.../demo/rest/data/file/23/type``. + +By setting the header to ``Accept: application/octet-stream; q=1.0, +application/json; q=0.5``, you will receive the binary PNG file with +the header ``Content-Type: application/octet-stream``. If you switch +the ``q`` values, you will receive the encoded JSON version:: + + { + "data": { + "id": "23", + "type": "<class 'bytes'>", + "link": "https://.../demo/rest/data/file/23/binary_content", + "data": "b'\\x89PNG\\r\\n\\x1a\\n\\x00[...]0\\x00\\x00\\x00IEND\\xaeB`\\x82'", + "@etag": "\"db6adc1b09d95b0388d79c7905bc7982\"" + } + } + +with ``Content-Type: application/json`` and a (4x larger) json encoded +representation of the binary data. + +If you want it returned with a ``Content-Type: image/png`` header, +you can use ``image/png`` or ``*/*`` in the Accept header. + +For message files, you can use +``https://.../demo/rest/data/msg/23/binary_content`` with ``Accept: +application/octet-stream; q=0.5, application/json; q=0.4, image/png; +q=0.495, text/*``. It will return the plain text of the message. + +Most message files are not stored with a mime type. Getting +``https://.../demo/rest/data/msg/23/type`` returns:: + + { + "data": { + "id": "23", + "type": "<class 'NoneType'>", + "link": "https://.../demo/rest/data/msg/23/type", + "data": null, + "@etag": "\"ba98927a8bb4c56f6cfc31a36f94ad16\"" + } + } + +The data attribute will usually be null/empty. As a result, mime type +matching for an item without a mime type is forgiving. + +Messages are meant to be human readable, so the mime type ``text/*`` +can be used to access any text style mime type (``text/plain``, +``text/x-rst``, ``text/markdown``, ``text/html``, ...) or an empty +mime type. If the item's type is not empty, it will be used as the +Content-Type (similar to ``*/*``). Otherwise ``text/*`` will be the +Content-Type. If your tracker supports markup languages +(e.g. markdown), you should set the mime type (e.g. ``text/markdown``) +when storing your message. + +Note that the header ``X-Content-Type-Options: nosniff`` is returned +with a non javascript or xml binary_content response to prevent the +browser from trying to interpret the returned data. + +Legacy Method (HTML interface) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +With the addition of file binary content streaming in the rest +interface to Roundup 2.5.0, this method (using the html interface) is +considered legacy but still works. + To retreive the content, you can use the content link property: ``https://.../demo/msg11/``. The trailing / is required. Without the /, you get a web page that includes metadata about the message. With
--- a/roundup/rest.py Sun Dec 08 09:11:53 2024 -0500 +++ b/roundup/rest.py Sun Dec 08 17:22:33 2024 -0500 @@ -433,7 +433,6 @@ __default_patch_op = "replace" # default operator for PATCH method __accepted_content_type = { "application/json": "json", - "*/*": "json", } __default_accept_type = "json" @@ -2232,6 +2231,8 @@ 3) if empty or missing Accept header return self.__default_accept_type 4) match and return best Accept header/version + this includes matching mime types for file downloads + using the binary_content property if version error found in matching type return 406 error 5) if no requested format is supported return 406 error @@ -2281,9 +2282,9 @@ self.client.response_code = 406 return (None, uri, self.error_obj( 400, _("Unable to parse Accept Header. %(error)s. " - "Acceptable types: %(acceptable_types)s") % { + "Acceptable types: */*, %(acceptable_types)s") % { 'error': e.args[0], - 'acceptable_types': " ".join(sorted( + 'acceptable_types': ", ".join(sorted( self.__accepted_content_type.keys()))})) if not accept_header: @@ -2291,11 +2292,45 @@ return (self.__default_accept_type, uri, None) accept_type = "" + valid_binary_content_types = [] + if uri.endswith("/binary_content"): + request_path = uri + request_class, request_id = request_path.split('/')[-3:-1] + try: + designator_type = self.db.getclass( + request_class).get(request_id, "type") + except (KeyError, IndexError): + # class (KeyError) or + # id (IndexError) does not exist + # Return unknown mime type and no error. + # The 400/404 error will be thrown by other code. + return (None, uri, None) + + if designator_type: + # put this first as we usually require exact mime + # type match and this will be matched most often. + # Also for text/* Accept header it will be returned. + valid_binary_content_types.append(designator_type) + + if not designator_type or designator_type.startswith('text/'): + # allow text/* as msg items can have empty type field + # also match text/* for text/plain, text/x-rst, + # text/markdown, text/html etc. + valid_binary_content_types.append("text/*") + + # Octet-stream should be allowed for any content. + # client.py sets 'X-Content-Type-Options: nosniff' + # for file downloads (sendfile) via the html interface, + # so we should be able to set it in this code as well. + valid_binary_content_types.append("application/octet-stream") + for part in accept_header: if accept_type: # we accepted the best match, stop searching for # lower quality matches. break + + # check for structured rest return types (json xml) if part[0] in self.__accepted_content_type: accept_type = self.__accepted_content_type[part[0]] # Version order: @@ -2311,6 +2346,8 @@ # use default if version = None try: self.api_version = int(part[1]['version']) + if self.api_version not in self.__supported_api_versions: + raise ValueError except KeyError: self.api_version = None except (ValueError, TypeError): @@ -2323,17 +2360,45 @@ return (None, uri, self.error_obj(406, msg)) + if part[0] == "*/*": + if valid_binary_content_types: + self.client.setHeader("X-Content-Type-Options", "nosniff") + accept_type = valid_binary_content_types[0] + else: + accept_type = "json" + + # check type of binary_content + if part[0] in valid_binary_content_types: + self.client.setHeader("X-Content-Type-Options", "nosniff") + accept_type = part[0] + # handle text wildcard + if ((part[0] in 'text/*') and + "text/*" in valid_binary_content_types): + self.client.setHeader("X-Content-Type-Options", "nosniff") + # use best choice of mime type, try not to use + # text/* if there is a real text mime type/subtype. + accept_type = valid_binary_content_types[0] + # accept_type will be empty only if there is an Accept header # with invalid values. if accept_type: return (accept_type, uri, None) - self.client.response_code = 400 + if valid_binary_content_types: + return (None, uri, + self.error_obj( + 406, + _("Requested content type(s) '%s' not available.\n" + "Acceptable mime types are: */*, %s") % + (self.client.request.headers.get('Accept'), + ", ".join(sorted( + valid_binary_content_types))))) + return (None, uri, self.error_obj( 406, _("Requested content type(s) '%s' not available.\n" - "Acceptable mime types are: %s") % + "Acceptable mime types are: */*, %s") % (self.client.request.headers.get('Accept'), ", ".join(sorted( self.__accepted_content_type.keys()))))) @@ -2597,14 +2662,20 @@ output = '<?xml version="1.0" encoding="UTF-8" ?>\n' + \ b2s(dicttoxml(output, root=False)) + elif accept_mime_type: + self.client.setHeader("Content-Type", accept_mime_type) + # do not send etag when getting binary_content. The ETag + # is for the item not the content of the item. So the ETag + # can change even though the content is the same. Since + # content is immutable by default, the client shouldn't + # need the etag for writing. + self.client.setHeader("ETag", None) + return output['data']['data'] else: - # FIXME?? consider moving this earlier. We should - # error out before doing any work if we can't - # display acceptable output. - self.client.response_code = 406 - output = ("Requested content type '%s' is not available.\n" - "Acceptable types: %s" % (accept_mime_type, - ", ".join(sorted(self.__accepted_content_type.keys())))) + self.client.response_code = 500 + output = _("Internal error while formatting response.\n" + "accept_mime_type is not defined. This should\n" + "never happen\n") # Make output json end in a newline to # separate from following text in logs etc..
--- a/test/rest_common.py Sun Dec 08 09:11:53 2024 -0500 +++ b/test/rest_common.py Sun Dec 08 17:22:33 2024 -0500 @@ -7,6 +7,7 @@ from datetime import datetime, timedelta from roundup.anypy.cgi_ import cgi from roundup.anypy.datetime_ import utcnow +from roundup.date import Date from roundup.exceptions import UsageError from roundup.test.tx_Source_detector import init as tx_Source_init @@ -102,6 +103,29 @@ self.db.user.set('1', address="admin@admin.com") self.db.user.set('2', address="anon@admin.com") + + # set up some more stuff for testing + self.db.msg.create( + author="1", + date=Date(), + summary="stuff", + content="abcdefghi\njklmnop", + type="text/markdown" + ) + + self.db.msg.create( + author="1", + date=Date(), + summary="stuff", + content="abcdefghi\njklmnop", + ) + + self.db.file.create( + name="afile", + content="PNG\x01abcdefghi\njklmnop", + type="image/png" + ) + self.db.commit() self.db.close() self.db = self.instance.open('joe') @@ -1947,7 +1971,7 @@ self.assertEqual(self.server.client.response_code, 400) self.assertEqual(output_type, None) self.assertEqual(uri, "/rest/data/issue") - self.assertIn('Unable to parse Accept Header. Invalid media type: Xyzzy I am not a mime. Acceptable types: */* application/json', error['error']['msg']) + self.assertIn('Unable to parse Accept Header. Invalid media type: Xyzzy I am not a mime. Acceptable types: */*, application/json', error['error']['msg']) # test 5 accept mimetype is ok, param is not headers={"accept": "*/*; foo", @@ -1969,7 +1993,298 @@ self.assertEqual(self.server.client.response_code, 400) self.assertEqual(output_type, None) self.assertEqual(uri, "/rest/data/issue") - self.assertIn('Unable to parse Accept Header. Invalid param: foo. Acceptable types: */* application/json', error['error']['msg']) + self.assertIn('Unable to parse Accept Header. Invalid param: foo. Acceptable types: */*, application/json', error['error']['msg']) + + # test 6: test paths: + # + test_suite = [ + (# use binary_content on a class that doesn't support it + {"path": "/rest/data/issue/1/binary_content", + "accept": "", + "response_code": "", + "output_type": None, + "uri": "/rest/data/issue/1/binary_content", + "error": None + }), + (# use invalid class + {"path": "/rest/data/notissue/1/binary_content", + "accept": "", + "response_code": "", + "output_type": None, + "uri": "/rest/data/notissue/1/binary_content", + "error": None + }), + (# use invalid id + {"path": "/rest/data/issue/99/binary_content", + "accept": "", + "response_code": "", + "output_type": None, + "uri": "/rest/data/issue/99/binary_content", + "error": None + }), + ] + + for test in test_suite: + self.server.client.response_code = "" + env = { "CONTENT_TYPE": "application/json", + "CONTENT_LENGTH": len(body), + "REQUEST_METHOD": "GET" + } + self.server.client.env.update(env) + headers={"accept": test["accept"] or + "application/zot; version=1; q=0.75, " + "application/json; version=1; q=0.5", + "content-type": env['CONTENT_TYPE'], + "content-length": env['CONTENT_LENGTH'], + } + + self.headers=headers + # we need to generate a FieldStorage the looks like + # FieldStorage(None, None, 'string') rather than + # FieldStorage(None, None, []) + body_file=BytesIO(body) # FieldStorage needs a file + form = client.BinaryFieldStorage( + body_file, + headers=headers, + environ=env) + self.server.client.request.headers.get=self.get_header + (output_type, uri, error) = dof(test["path"]) + + self.assertEqual(self.server.client.response_code, + test["response_code"]) + self.assertEqual(output_type, test["output_type"]) + self.assertEqual(uri, test["uri"]) + self.assertEqual(error, test["error"]) + + # test 7: test paths: + # + test_suite = [ + (# use wildcard accept on item and get back json output + {"path": "/rest/data/file/1", + "accept": "*/*", + "response_code": "", + "output_type": "json", + "uri": "/rest/data/file/1", + "error": None, + "has_nosniff": False, + }), + (# use wildcard accept and get back file's actual mime type + {"path": "/rest/data/file/1/binary_content", + "accept": "*/*", + "response_code": "", + "output_type": "image/png", + "uri": "/rest/data/file/1/binary_content", + "error": None, + "has_nosniff": True, + + }), + (# use json accept and get back json + {"path": "/rest/data/file/1/binary_content", + "accept": "application/json", + "response_code": "", + "output_type": "json", + "uri": "/rest/data/file/1/binary_content", + "error": None, + "has_nosniff": False, + }), + (# use json accept with invalid number version and get back error + {"path": "/rest/data/file/1/binary_content", + "accept": "application/json; q=0.5; version=22", + "response_code": 406, + "output_type": None, + "uri": "/rest/data/file/1/binary_content", + "error": {'error': {'status': 406, 'msg': 'Unrecognized api version: 22. See /rest without specifying api version for supported versions.'}}, + "has_nosniff": False, + }), + (# use json accept with invalid string version and get back error + {"path": "/rest/data/file/1/binary_content", + "accept": "application/json; q=0.5; version=z", + "response_code": 406, + "output_type": None, + "uri": "/rest/data/file/1/binary_content", + "error": {'error': {'status': 406, 'msg': 'Unrecognized api version: z. See /rest without specifying api version for supported versions.'}}, + "has_nosniff": False, + }), + (# use octet-stream accept and get back octet-stream mime type + {"path": "/rest/data/file/1/binary_content", + "accept": "application/octet-stream; q=0.9, */*; q=0.5", + "response_code": "", + "output_type": "application/octet-stream", + "uri": "/rest/data/file/1/binary_content", + "error": None, + "has_nosniff": True, + }), + (# use image/png accept and get back image/png mime type + {"path": "/rest/data/file/1/binary_content", + "accept": "application/octet-stream; q=0.9, image/png", + "response_code": "", + "output_type": "image/png", + "uri": "/rest/data/file/1/binary_content", + "error": None, + "has_nosniff": True, + }), + (# use invalid accept and get back error + {"path": "/rest/data/file/1/binary_content", + "accept": "image/svg+html", + "response_code": 406, + "output_type": None, + "uri": "/rest/data/file/1/binary_content", + "error": {'error': + {'status': 406, 'msg': "Requested content type(s) 'image/svg+html' not available.\nAcceptable mime types are: */*, application/octet-stream, image/png"}}, + "has_nosniff": False, + }), + (# use wildcard accept and get back msg's actual mime type + {"path": "/rest/data/msg/1/binary_content", + "accept": "*/*", + "response_code": "", + "output_type": "text/markdown", + "uri": "/rest/data/msg/1/binary_content", + "error": None, + "has_nosniff": True, + }), + (# use octet-stream accept and get back octet-stream mime type + {"path": "/rest/data/msg/1/binary_content", + "accept": "application/octet-stream; q=0.9, */*; q=0.5", + "response_code": "", + "output_type": "application/octet-stream", + "uri": "/rest/data/msg/1/binary_content", + "error": None, + "has_nosniff": True, + }), + + (# use wildcard text accept and get back msg's actual mime type + {"path": "/rest/data/msg/1/binary_content", + "accept": "text/*", + "response_code": "", + "output_type": "text/markdown", + "uri": "/rest/data/msg/1/binary_content", + "error": None, + "has_nosniff": True, + }), + (# use wildcard text accept and get back file's actual mime type + {"path": "/rest/data/msg/1/binary_content", + "accept": "text/markdown", + "response_code": "", + "output_type": "text/markdown", + "uri": "/rest/data/msg/1/binary_content", + "error": None, + "has_nosniff": True, + }), + (# use text/plain accept and get back test/plain + {"path": "/rest/data/msg/1/binary_content", + "accept": "text/plain", + "response_code": 406, + "output_type": None, + "uri": "/rest/data/msg/1/binary_content", + "error": {'error': + {'status': 406, 'msg': + "Requested content type(s) 'text/plain' not available.\nAcceptable mime types are: */*, application/octet-stream, text/*, text/markdown"}}, + "has_nosniff": False, + }), + (# use wildcard accept and get back default msg mime type + {"path": "/rest/data/msg/2/binary_content", + "accept": "*/*", + "response_code": "", + "output_type": "text/*", + "uri": "/rest/data/msg/2/binary_content", + "error": None, + "has_nosniff": True, + }), + (# use text/* and get back text/* + {"path": "/rest/data/msg/2/binary_content", + "accept": "text/*", + "response_code": "", + "output_type": "text/*", + "uri": "/rest/data/msg/2/binary_content", + "error": None, + "has_nosniff": True, + }), + (# use text/markdown and get back error + {"path": "/rest/data/msg/2/binary_content", + "accept": "text/markdown", + "response_code": 406, + "output_type": None, + "uri": "/rest/data/msg/2/binary_content", + "error": {'error': + {'status': 406, 'msg': + "Requested content type(s) 'text/markdown' not available.\nAcceptable mime types are: */*, application/octet-stream, text/*"}}, + "has_nosniff": False, + }), + (# use error accept and get back error + {"path": "/rest/data/msg/1/binary_content", + "accept": "text/markdown, q=2", + "response_code": 400, + "output_type": None, + "uri": "/rest/data/msg/1/binary_content", + "error": {'error': + {'status': 400, 'msg': + 'Unable to parse Accept Header. Invalid media type: q=2. Acceptable types: */*, application/json'}}, + "has_nosniff": False, + }), + (# use text/* but override with extension of .json get back json + {"path": "/rest/data/msg/2/binary_content.json", + "accept": "text/*", + "response_code": "", + "output_type": "json", + "uri": "/rest/data/msg/2/binary_content", + "error": None, + "has_nosniff": False, + }), + (# use text/* but override with extension of .jon get back error + {"path": "/rest/data/msg/2/binary_content.jon", + "accept": "text/*", + "response_code": 406, + "output_type": None, + "uri": "/rest/data/msg/2/binary_content.jon", + "error": {'error': + {'status': 406, 'msg': + "Content type 'jon' requested in URL is not available.\nAcceptable types: json\n"}}, + "has_nosniff": False, + }), + ] + + for test in test_suite: + print(test) + self.server.client.response_code = "" + self.server.client.additional_headers = {} + env = { "CONTENT_TYPE": "application/json", + "CONTENT_LENGTH": len(body), + "REQUEST_METHOD": "GET" + } + self.server.client.env.update(env) + headers={"accept": test["accept"] or + "application/zot; version=1; q=0.75, " + "application/json; version=1; q=0.5", + "content-type": env['CONTENT_TYPE'], + "content-length": env['CONTENT_LENGTH'], + } + + self.headers=headers + # we need to generate a FieldStorage the looks like + # FieldStorage(None, None, 'string') rather than + # FieldStorage(None, None, []) + body_file=BytesIO(body) # FieldStorage needs a file + form = client.BinaryFieldStorage( + body_file, + headers=headers, + environ=env) + self.server.client.request.headers.get=self.get_header + (output_type, uri, error) = dof(test["path"]) + + self.assertEqual(self.server.client.response_code, + test["response_code"]) + self.assertEqual(output_type, test["output_type"]) + self.assertEqual(uri, test["uri"]) + print(error) + self.assertEqual(error, test["error"]) + if test["has_nosniff"]: + self.assertIn("X-Content-Type-Options", + self.server.client.additional_headers) + self.assertEqual("nosniff", + self.server.client.additional_headers['X-Content-Type-Options']) + else: + self.assertNotIn("X-Content-Type-Options", + self.server.client.additional_headers) def testDispatchBadAccept(self): # simulate: /rest/data/issue expect failure unknown accept settings @@ -2086,7 +2401,7 @@ print(results) self.assertEqual(self.server.client.response_code, 400) json_dict = json.loads(b2s(results)) - self.assertIn('Unable to parse Accept Header. Invalid media type: Xyzzy I am not a mime. Acceptable types: */* application/json', json_dict['error']['msg']) + self.assertIn('Unable to parse Accept Header. Invalid media type: Xyzzy I am not a mime. Acceptable types: */*, application/json', json_dict['error']['msg']) # test 5 accept mimetype is ok, param is not headers={"accept": "*/*; foo", @@ -2110,7 +2425,7 @@ print(results) self.assertEqual(self.server.client.response_code, 400) json_dict = json.loads(b2s(results)) - self.assertIn('Unable to parse Accept Header. Invalid param: foo. Acceptable types: */* application/json', json_dict['error']['msg']) + self.assertIn('Unable to parse Accept Header. Invalid param: foo. Acceptable types: */*, application/json', json_dict['error']['msg']) def testStatsGen(self): # check stats being returned by put and get ops @@ -3354,8 +3669,7 @@ results = self.server.get_element('file', fileid, self.empty_form) results = results['data'] self.assertEqual(self.dummy_client.response_code, 200) - self.assertEqual(results['attributes']['content'], - {'link': 'http://tracker.example/cgi-bin/roundup.cgi/bugs/file1/'}) + self.assertIn("link", results['attributes']['content']) # File content is only shown with verbose=3 form = cgi.FieldStorage()
