예제 #1
0
def test_json_view_normal_response():
    """Normal responses get passed through."""
    expected = http.HttpResponseForbidden()
    f = lambda r: expected
    response = decorators.json_view(f)(mock.Mock())
    assert expected is response
    eq_(response['Content-Type'], 'text/html; charset=utf-8')
예제 #2
0
def test_json_view_normal_response():
    """Normal responses get passed through."""
    expected = http.HttpResponseForbidden()
    f = lambda r: expected
    response = decorators.json_view(f)(mock.Mock())
    assert expected is response
    eq_(response['Content-Type'], 'text/html; charset=utf-8')
예제 #3
0
def test_json_view():
    """Turns a Python object into a response."""
    f = lambda r: {'x': 1}
    response = decorators.json_view(f)(mock.Mock())
    assert isinstance(response, http.HttpResponse)
    eq_(response.content, '{"x": 1}')
    eq_(response['Content-Type'], 'application/json')
예제 #4
0
def test_json_view():
    """Turns a Python object into a response."""
    f = lambda r: {'x': 1}
    response = decorators.json_view(f)(mock.Mock())
    assert isinstance(response, http.HttpResponse)
    eq_(response.content, '{"x": 1}')
    eq_(response['Content-Type'], 'application/json')
예제 #5
0
def test_json_view():
    """Turns a Python object into a response."""
    f = lambda r: {"x": 1}
    response = decorators.json_view(f)(mock.Mock())
    assert isinstance(response, http.HttpResponse)
    eq_(response.content, '{"x": 1}')
    eq_(response["Content-Type"], "application/json")
    eq_(response.status_code, 200)
예제 #6
0
def test_json_view():
    """Turns a Python object into a response."""
    def func(request):
        return {'x': 1}

    response = decorators.json_view(func)(mock.Mock())
    assert isinstance(response, http.HttpResponse)
    eq_(response.content, '{"x": 1}')
    eq_(response['Content-Type'], 'application/json')
    eq_(response.status_code, 200)
예제 #7
0
def test_json_view_status():
    f = lambda r: {'x': 1}
    response = decorators.json_view(f, status_code=202)(mock.Mock())
    eq_(response.status_code, 202)
예제 #8
0
def test_json_view_status():
    f = lambda r: {'x': 1}
    response = decorators.json_view(f, status_code=202)(mock.Mock())
    eq_(response.status_code, 202)
예제 #9
0
def test_json_view_status():
    def func(request):
        return {'x': 1}

    response = decorators.json_view(func, status_code=202)(mock.Mock())
    eq_(response.status_code, 202)