本文整理汇总了Python中shop.views.cart.CartDetails.get_context_data方法的典型用法代码示例。如果您正苦于以下问题:Python CartDetails.get_context_data方法的具体用法?Python CartDetails.get_context_data怎么用?Python CartDetails.get_context_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shop.views.cart.CartDetails
的用法示例。
在下文中一共展示了CartDetails.get_context_data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_01_get_context_data_works
# 需要导入模块: from shop.views.cart import CartDetails [as 别名]
# 或者: from shop.views.cart.CartDetails import get_context_data [as 别名]
def test_01_get_context_data_works(self):
self.create_fixtures()
request = Mock()
setattr(request, 'user', self.user)
view = CartDetails(request=request)
ret = view.get_context_data()
self.assertNotEqual(ret,None)
示例2: _get_from_cart
# 需要导入模块: from shop.views.cart import CartDetails [as 别名]
# 或者: from shop.views.cart.CartDetails import get_context_data [as 别名]
def _get_from_cart(self):
request = Mock()
setattr(request, 'user', self.user)
view = CartDetails(request=request)
ret = view.get_context_data()
self.assertNotEqual(ret, None)
return ret
示例3: test_context_has_as_many_items_as_cart
# 需要导入模块: from shop.views.cart import CartDetails [as 别名]
# 或者: from shop.views.cart.CartDetails import get_context_data [as 别名]
def test_context_has_as_many_items_as_cart(self):
self.cart.user = self.user
self.cart.save()
request = Mock()
setattr(request, 'user', self.user)
view = CartDetails(request=request)
ret = view.get_context_data()
self.assertNotEqual(ret,None)
self.assertEqual(len(ret['cart_items']),1)
self.assertEqual(ret['cart_items'][0], self.item)
示例4: test_calling_ajax_post_returns_content
# 需要导入模块: from shop.views.cart import CartDetails [as 别名]
# 或者: from shop.views.cart.CartDetails import get_context_data [as 别名]
def test_calling_ajax_post_returns_content(self):
self.cart.user = self.user
self.cart.save()
request = Mock()
setattr(request, "is_ajax", lambda: True)
setattr(request, "user", self.user)
setattr(request, "session", {})
post = {"add_item_id": self.product.pk, "add_item_quantity": 1}
setattr(request, "POST", post)
view = CartDetails(request=request)
ret = view.post()
self.assertTrue(isinstance(ret, HttpResponse))
ret = view.get_context_data()
self.assertNotEqual(ret, None)
self.assertEqual(len(ret["cart_items"]), 1)
self.assertEqual(ret["cart_items"][0], self.item)
self.assertEqual(ret["cart_items"][0].quantity, 2)
示例5: test_calling_ajax_post_returns_content
# 需要导入模块: from shop.views.cart import CartDetails [as 别名]
# 或者: from shop.views.cart.CartDetails import get_context_data [as 别名]
def test_calling_ajax_post_returns_content(self):
self.cart.user = self.user
self.cart.save()
request = Mock()
setattr(request, 'is_ajax', lambda :True)
setattr(request, 'user', self.user)
post={
'add_item_id':self.product.id,
'add_item_quantity':1,
}
setattr(request, 'POST', post)
view = CartDetails(request=request)
ret = view.post()
self.assertTrue(isinstance(ret,HttpResponse))
ret = view.get_context_data()
self.assertNotEqual(ret,None)
self.assertEqual(len(ret['cart_items']),1)
self.assertEqual(ret['cart_items'][0], self.item)
self.assertEqual(ret['cart_items'][0].quantity, 2)
示例6: test_get_context_data_works
# 需要导入模块: from shop.views.cart import CartDetails [as 别名]
# 或者: from shop.views.cart.CartDetails import get_context_data [as 别名]
def test_get_context_data_works(self):
request = Mock()
setattr(request, "user", self.user)
view = CartDetails(request=request)
ret = view.get_context_data()
self.assertNotEqual(ret, None)