在我的 django 应用程序中,我有一个认证系统。因此,如果我不登录,并尝试访问一些个人资料的个人信息,我会被重定向到登录页面。
现在,我需要为此编写一个测试用例,我从浏览器得到的响应是:
GET /myprofile/data/some_id/ HTTP/1.1 302 0
GET /account/login?next=/myprofile/data/some_id/ HTTP/1.1 301 0
GET /account/login?next=/myprofile/data/some_id/ HTTP/1.1 200 6533
我如何写我的测试? 这就是我到目前为止所知道的:
self.client.login(user="user", password="passwd")
response = self.client.get('/myprofile/data/some_id/')
self.assertEqual(response.status,200)
self.client.logout()
response = self.client.get('/myprofile/data/some_id/')
接下来会发生什么?