Exemplo n.º 1
0
def test_method_not_allowed(rf, method, status_code):
    from django_handlers import Handler

    handler = Handler()

    @handler.get('something')
    def get_something(request):
        return HttpResponse()

    @handler.put('something')
    def post_something(request):
        return HttpResponse()

    request = getattr(rf, method)('/something')
    response = handler.something(request)
    assert response.status_code == status_code
Exemplo n.º 2
0
def test_method(rf, method):
    from django_handlers import Handler

    handler = Handler()

    @handler.get('something')
    def get(request):
        return HttpResponse('get')

    @handler.head('something')
    def head(request):
        return HttpResponse('head')

    @handler.options('something')
    def options(request):
        return HttpResponse('options')

    @handler.post('something')
    def post(request):
        return HttpResponse('post')

    @handler.put('something')
    def put(request):
        return HttpResponse('put')

    @handler.patch('something')
    def patch(request):
        return HttpResponse('patch')

    @handler.delete('something')
    def delete(request):
        return HttpResponse('delete')

    request = getattr(rf, method)('/something')
    response = handler.something(request)
    assert response.content.decode('utf-8') == method