Mercurial > p > roundup > code
diff test/rest_common.py @ 7372:886a5c767d7e
Invalid REST item spec returns 404 rather than 400.
A GET to /rest/data/issue/issue4 now returns a 404 rather than a 400
status code.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 17 May 2023 22:20:12 -0400 |
| parents | 2de72f75f2f8 |
| children | 613f822f1f24 |
line wrap: on
line diff
--- a/test/rest_common.py Wed May 17 13:34:36 2023 -0400 +++ b/test/rest_common.py Wed May 17 22:20:12 2023 -0400 @@ -1354,6 +1354,27 @@ json_dict = json.loads(b2s(results)) self.assertEqual(json_dict,expected) + + def testDispatchGet(self): + self.create_sampledata() + + form = cgi.FieldStorage() + self.server.client.request.headers.get=self.get_header + + for item in [ "55", "issue1", "1" ]: + print("test item: '%s'" % item) + results = self.server.dispatch("GET", + "/rest/data/issue/%s" % item, + form) + json_dict = json.loads(b2s(results)) + try: + self.assertEqual(json_dict['error']['status'], 404) + except KeyError as e: + if e.args[0] == "error" and item == "1": + pass + else: + self.assertTrue(False) + def testDispatchPost(self): """ run POST through rest dispatch(). This also tests
