예제 #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)