本文整理匯總了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)