def test_exception_handler(self, exception_handler_mock): exception_handler_mock.return_value = None resp = resolwe_exception_handler(Exception, {}) self.assertEqual(resp, None) exception_handler_mock.return_value = None resp = resolwe_exception_handler(ValidationError('Error description'), {}) self.assertEqual(resp.status_code, 400) self.assertEqual(resp.data['error'], 'Error description') original_resp = Response({}) exception_handler_mock.return_value = original_resp resp = resolwe_exception_handler(ValidationError('Error description'), {}) self.assertEqual(id(original_resp), id(resp)) self.assertEqual(resp.status_code, 400) self.assertEqual(resp.data['error'], 'Error description')