def test_request_id_presence(self): body = '' status = '400 Bad Request' title = '' # no request id in environ, none in error result = util.json_error_formatter(body, status, title, self.environ) self.assertNotIn('request_id', result['errors'][0]) # request id in environ, request id in error self.environ[request_id.ENV_REQUEST_ID] = 'stub-id' result = util.json_error_formatter(body, status, title, self.environ) self.assertEqual('stub-id', result['errors'][0]['request_id'])
def test_strip_body_tags(self): body = '<h1>Big Error!</h1>' status = '400 Bad Request' title = '' result = util.json_error_formatter(body, status, title, self.environ) self.assertEqual('Big Error!', result['errors'][0]['detail'])
def test_status_to_int_code(self): body = '' status = '404 Not Found' title = '' result = util.json_error_formatter(body, status, title, self.environ) self.assertEqual(404, result['errors'][0]['status'])