Esempio n. 1
0
 def test_format_error_no_request_id(self):
     req = FakeRequest()
     response = Service.format_error(APIError('bad thing'), req)
     assert req.code == 500
     assert req.headers == {'content-type': ['application/json']}
     assert json.loads(response) == {
         'request_id': None,
         'error': 'bad thing',
     }
Esempio n. 2
0
 def test_format_error_with_status_code(self):
     req = FakeRequest()
     Service.set_request_id(req, 'req0')
     response = Service.format_error(APIError('teapot', 418), req)
     assert req.code == 418
     assert req.headers == {'content-type': ['application/json']}
     assert json.loads(response) == {
         'request_id': 'req0',
         'error': 'teapot',
     }