tests.py 文件源码

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

项目:beg-django-e-commerce 作者: Apress 项目源码 文件源码
def test_add_to_cart_fails_csrf(self):
        """ adding product fails without including the CSRF token to POST request parameters """
        quantity = 2
        product_url = self.product.get_absolute_url()
        response = self.client.get(product_url)
        self.assertEqual(response.status_code, httplib.OK )

        # perform the post of adding to the cart
        postdata = {'product_slug': self.product.slug, 
                    'quantity': quantity }
        response = self.client.post(product_url, postdata )

        # assert forbidden error due to missing CSRF input
        self.assertEqual(response.status_code, httplib.FORBIDDEN )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号