|
@@ -10,6 +10,7 @@ from hapic.decorator import InputOutputControllerWrapper
|
10
|
10
|
from hapic.decorator import ExceptionHandlerControllerWrapper
|
11
|
11
|
from hapic.decorator import InputControllerWrapper
|
12
|
12
|
from hapic.decorator import OutputControllerWrapper
|
|
13
|
+from hapic.hapic import ErrorResponseSchema
|
13
|
14
|
from hapic.processor import RequestParameters
|
14
|
15
|
from hapic.processor import MarshmallowOutputProcessor
|
15
|
16
|
from hapic.processor import ProcessValidationError
|
|
@@ -207,6 +208,7 @@ class TestExceptionHandlerControllerWrapper(Base):
|
207
|
208
|
wrapper = ExceptionHandlerControllerWrapper(
|
208
|
209
|
ZeroDivisionError,
|
209
|
210
|
context,
|
|
211
|
+ schema=ErrorResponseSchema(),
|
210
|
212
|
http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
211
|
213
|
)
|
212
|
214
|
|
|
@@ -219,7 +221,9 @@ class TestExceptionHandlerControllerWrapper(Base):
|
219
|
221
|
assert response['http_code'] == HTTPStatus.INTERNAL_SERVER_ERROR
|
220
|
222
|
assert 'original_response' in response
|
221
|
223
|
assert response['original_response'] == {
|
222
|
|
- 'error_message': 'We are testing',
|
|
224
|
+ 'message': 'We are testing',
|
|
225
|
+ 'code': None,
|
|
226
|
+ 'detail': {},
|
223
|
227
|
}
|
224
|
228
|
|
225
|
229
|
def test_unit__exception_handled__ok__exception_error_dict(self):
|
|
@@ -232,13 +236,14 @@ class TestExceptionHandlerControllerWrapper(Base):
|
232
|
236
|
wrapper = ExceptionHandlerControllerWrapper(
|
233
|
237
|
MyException,
|
234
|
238
|
context,
|
|
239
|
+ schema=ErrorResponseSchema(),
|
235
|
240
|
http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
236
|
241
|
)
|
237
|
242
|
|
238
|
243
|
@wrapper.get_wrapper
|
239
|
244
|
def func(foo):
|
240
|
245
|
exc = MyException('We are testing')
|
241
|
|
- exc.error_dict = {'foo': 'bar'}
|
|
246
|
+ exc.error_detail = {'foo': 'bar'}
|
242
|
247
|
raise exc
|
243
|
248
|
|
244
|
249
|
response = func(42)
|
|
@@ -246,6 +251,7 @@ class TestExceptionHandlerControllerWrapper(Base):
|
246
|
251
|
assert response['http_code'] == HTTPStatus.INTERNAL_SERVER_ERROR
|
247
|
252
|
assert 'original_response' in response
|
248
|
253
|
assert response['original_response'] == {
|
249
|
|
- 'error_message': 'We are testing',
|
250
|
|
- 'foo': 'bar',
|
|
254
|
+ 'message': 'We are testing',
|
|
255
|
+ 'code': None,
|
|
256
|
+ 'detail': {'foo': 'bar'},
|
251
|
257
|
}
|