test_view_case.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:django-skivvy 作者: Cadasta 项目源码 文件源码
def test_request_get():
    class TheCase(ViewTestCase, TestCase):
        view_class = views.GenericView
        request_meta = {'HTTP_REFERER': 'http://example.com'}

    user = User(username='user')
    case = TheCase()
    response = case.request(user=user)

    assert case._request.user == user
    assert case._request.method == 'GET'
    assert case._request.META['SERVER_NAME'] == 'testserver'
    assert case._request.META['SERVER_PORT'] == '80'
    assert case._request.META['HTTP_REFERER'] == 'http://example.com'

    assert response.status_code == 200
    assert response.content == '<h1>Test content<h1>'
    assert response.location is None
    assert 'content-type' in response.headers
    assert len(response.messages) == 1
    assert 'Hello world.' in response.messages
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号