@override_settings(DEBUG=True)
    def test_api_decorator_debug(self):
        @api({
            'accepts': {
                'im_required': forms.IntegerField(),
                'ok': forms.IntegerField(required=False),
            },
            'returns': {
                200: 'OK',
                403: 'Permission denied',
            },
        })
        def simple_view(request):
            if request.GET['ok']:
                return JsonResponse()
            else:
                return JsonResponseAccepted()  # Not declared in @api_returns

        rf = RequestFactory()
        request = rf.get('/simple_view', data={'im_required': '1', 'ok': '1'})
        response = simple_view(request)
        self.assertEquals(response.status_code, 200)

        # fail accepts
        request = rf.get('/simple_view', data={'ok': '1'})
        response = simple_view(request)
        self.assertEquals(response.status_code, 400)

        # fail returns
        request = rf.get('/simple_view', data={'im_required': '1'})
        response = simple_view(request)
        self.assertEquals(response.status_code, 400)
Test that the @api decorator (in debug mode)
dataset/ETHPy150Open bipsandbytes/django-api/django_api/tests.py/SimpleTest.test_api_decorator_debug