tests.py 文件源码

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

项目:DRF-tutorial 作者: TangentSolutions 项目源码 文件源码
def test_logged_in_user_can_edit_self(self):
        """GET /user/{pk} A user should be able to edit their own details"""

        self.c.login(username="joe", password="password")
        url = reverse("user-detail", args=[self.normal_user.pk])

        data = {
            "username": "joe",
            "first_name": "Joe", 
            "last_name": "Soap",
        }

        response = self.c.put(url, data, format="json")

        assert response.status_code == 200, \
            "Expect 200 OK. got: {}: {}" . format(response.status_code, response.content)

        joe = User.objects.get(username="joe")

        assert joe.first_name == "Joe", \
            "Expect user's first_name to be Joe. Got: {}" . format(joe.first_name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号