

@override_settings(DEBUG=True)
def test_api_decorator_debug(self):
    '\n        Test that the @api decorator (in debug mode)\n        '

    @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()
    rf = RequestFactory()
    request = rf.get('/simple_view', data={
        'im_required': '1',
        'ok': '1',
    })
    response = simple_view(request)
    self.assertEquals(response.status_code, 200)
    request = rf.get('/simple_view', data={
        'ok': '1',
    })
    response = simple_view(request)
    self.assertEquals(response.status_code, 400)
    request = rf.get('/simple_view', data={
        'im_required': '1',
    })
    response = simple_view(request)
    self.assertEquals(response.status_code, 400)

dataset/ETHPy150Open bipsandbytes/django-api/django_api/tests.py SimpleTest.test_api_decorator_debug/original