test_api_case.py 文件源码

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

项目:django-skivvy 作者: Cadasta 项目源码 文件源码
def test_request_post():
    class TheCase(APITestCase, TestCase):
        view_class = APITestView
        post_data = {'some': 'json'}

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

    assert case._request.user == user
    assert case._request.method == 'POST'

    assert response.status_code == 200
    assert isinstance(response.content, dict)
    assert response.content == {"some": "json"}
    assert response.location is None
    assert 'content-type' in response.headers
    assert response.headers['content-type'][1] == 'application/json'
    assert len(response.messages) == 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号