示例#1
0
def test_json_view_normal_response():
    """Normal responses get passed through."""
    expected = http.HttpResponseForbidden()
    f = lambda r: expected
    response = 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 = 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."""
    response = json_view(lambda r: {'x': 1})(mock.Mock())
    assert isinstance(response, http.HttpResponse)
    eq_(response.content, '{"x": 1}')
    eq_(response['Content-Type'], 'application/json')
    eq_(response.status_code, 200)
示例#4
0
def test_json_view():
    """Turns a Python object into a response."""
    response = json_view(lambda r: {'x': 1})(mock.Mock())
    assert isinstance(response, http.HttpResponse)
    eq_(response.content, '{"x": 1}')
    eq_(response['Content-Type'], 'application/json')
    eq_(response.status_code, 200)
示例#5
0
def test_json_view_status():
    f = lambda r: {'x': 1}
    response = json_view(f, status_code=202)(mock.Mock())
    eq_(response.status_code, 202)
示例#6
0
def test_json_view_status():
    f = lambda r: {'x': 1}
    response = json_view(f, status_code=202)(mock.Mock())
    eq_(response.status_code, 202)