Browse Source

fix tests

Bastien Sevajol 6 years ago
parent
commit
4d2a83d93d
1 changed files with 15 additions and 16 deletions
  1. 15 16
      tests/unit/test_decorator.py

+ 15 - 16
tests/unit/test_decorator.py View File

248
 
248
 
249
         result = func(42)
249
         result = func(42)
250
         assert HTTPStatus.INTERNAL_SERVER_ERROR == result.status_code
250
         assert HTTPStatus.INTERNAL_SERVER_ERROR == result.status_code
251
-        # see MyProcessor#process
252
-        assert isinstance(result, dict)
253
-        assert 'http_code' in result
254
-        assert result['http_code'] == HTTPStatus.INTERNAL_SERVER_ERROR
255
-        assert 'original_error' in result
256
-        assert result['original_error'].details == {
257
-            'name': ['Missing data for required field.']
258
-        }
251
+        assert {
252
+                   'original_error': {
253
+                       'details': {
254
+                           'name': ['Missing data for required field.']
255
+                       },
256
+                       'message': 'Validation error of output data'
257
+                   },
258
+                   'http_code': 500,
259
+               } == json.loads(result.body)
259
 
260
 
260
 
261
 
261
 class TestExceptionHandlerControllerWrapper(Base):
262
 class TestExceptionHandlerControllerWrapper(Base):
273
             raise ZeroDivisionError('We are testing')
274
             raise ZeroDivisionError('We are testing')
274
 
275
 
275
         response = func(42)
276
         response = func(42)
276
-        assert 'http_code' in response
277
-        assert response['http_code'] == HTTPStatus.INTERNAL_SERVER_ERROR
278
-        assert 'original_response' in response
279
-        assert json.loads(response['original_response']) == {
280
-            'message': 'We are testing',
281
-            'details': {},
282
-            'code': None,
283
-        }
277
+        assert HTTPStatus.INTERNAL_SERVER_ERROR == response.status_code
278
+        assert {
279
+                   'details': {},
280
+                   'message': 'We are testing',
281
+                   'code': None,
282
+               } == json.loads(response.body)
284
 
283
 
285
     def test_unit__exception_handled__ok__exception_error_dict(self):
284
     def test_unit__exception_handled__ok__exception_error_dict(self):
286
         class MyException(Exception):
285
         class MyException(Exception):