diff test/rest_common.py @ 5984:25a813415d59

issue2551069 - when unsupported type is found report type When reporting an unsupported response type, error 406, report what type is seen by the code. Allows the user to better debug the query. E.G. look at the url and see if they mistyped it (e.g. by leaving a ? out of the url), or a mispelled accept header value or ....
author John Rouillard <rouilj@ieee.org>
date Tue, 26 Nov 2019 09:55:09 -0500
parents 5d0873a4de4a
children f1191a470598
line wrap: on
line diff
--- a/test/rest_common.py	Sat Nov 23 15:18:02 2019 -0500
+++ b/test/rest_common.py	Tue Nov 26 09:55:09 2019 -0500
@@ -1544,7 +1544,8 @@
 
 
         # TEST #8
-        # DELETE: delete issue 1
+        # DELETE: delete issue 1 also test return type by extension
+        #         test bogus extension as well.
         etag = calculate_etag(self.db.issue.getnode("1"),
                               self.db.config['WEB_SECRET_KEY'])
         etagb = etag.strip ('"')
@@ -1569,11 +1570,20 @@
                             "/rest/data/issue/1.json",
                             form)
         self.assertEqual(self.server.client.response_code, 200)
+        print(results)
         json_dict = json.loads(b2s(results))
-        print(results)
         status=json_dict['data']['status']
         self.assertEqual(status, 'ok')
 
+        results = self.server.dispatch('DELETE',
+                            "/rest/data/issue/1issue:=asdf.jon",
+                            form)
+        self.assertEqual(self.server.client.response_code, 406)
+        print(results)
+        response="Requested content type 'jon' is not available.\n" \
+                 "Acceptable types: */*, application/json, application/xml\n"
+        self.assertEqual(results, response)
+
         # TEST #9
         # GET: test that version can be set with accept:
         #    ... ; version=z

Roundup Issue Tracker: http://roundup-tracker.org/