comparison 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
comparison
equal deleted inserted replaced
5983:d877a2ac5ae4 5984:25a813415d59
1542 self.assertEqual(status, 400) 1542 self.assertEqual(status, 400)
1543 self.assertEqual(msg, "Must provide the 'name' property.") 1543 self.assertEqual(msg, "Must provide the 'name' property.")
1544 1544
1545 1545
1546 # TEST #8 1546 # TEST #8
1547 # DELETE: delete issue 1 1547 # DELETE: delete issue 1 also test return type by extension
1548 # test bogus extension as well.
1548 etag = calculate_etag(self.db.issue.getnode("1"), 1549 etag = calculate_etag(self.db.issue.getnode("1"),
1549 self.db.config['WEB_SECRET_KEY']) 1550 self.db.config['WEB_SECRET_KEY'])
1550 etagb = etag.strip ('"') 1551 etagb = etag.strip ('"')
1551 env = {"CONTENT_TYPE": "application/json", 1552 env = {"CONTENT_TYPE": "application/json",
1552 "CONTENT_LEN": 0, 1553 "CONTENT_LEN": 0,
1567 self.db.setCurrentUser('admin') # must be admin to delete issue 1568 self.db.setCurrentUser('admin') # must be admin to delete issue
1568 results = self.server.dispatch('DELETE', 1569 results = self.server.dispatch('DELETE',
1569 "/rest/data/issue/1.json", 1570 "/rest/data/issue/1.json",
1570 form) 1571 form)
1571 self.assertEqual(self.server.client.response_code, 200) 1572 self.assertEqual(self.server.client.response_code, 200)
1573 print(results)
1572 json_dict = json.loads(b2s(results)) 1574 json_dict = json.loads(b2s(results))
1573 print(results)
1574 status=json_dict['data']['status'] 1575 status=json_dict['data']['status']
1575 self.assertEqual(status, 'ok') 1576 self.assertEqual(status, 'ok')
1577
1578 results = self.server.dispatch('DELETE',
1579 "/rest/data/issue/1issue:=asdf.jon",
1580 form)
1581 self.assertEqual(self.server.client.response_code, 406)
1582 print(results)
1583 response="Requested content type 'jon' is not available.\n" \
1584 "Acceptable types: */*, application/json, application/xml\n"
1585 self.assertEqual(results, response)
1576 1586
1577 # TEST #9 1587 # TEST #9
1578 # GET: test that version can be set with accept: 1588 # GET: test that version can be set with accept:
1579 # ... ; version=z 1589 # ... ; version=z
1580 # or 1590 # or

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