当前位置: 首页>>代码示例>>Python>>正文


Python CartDetails.get_context_data方法代码示例

本文整理汇总了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)
开发者ID:MechanisM,项目名称:django-shop,代码行数:9,代码来源:views.py

示例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
开发者ID:jrief,项目名称:django-shop-productvariations,代码行数:9,代码来源:tests.py

示例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)
开发者ID:AlexHill,项目名称:django-shop,代码行数:12,代码来源:views.py

示例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)
开发者ID:berrym72,项目名称:django-shop,代码行数:23,代码来源:views.py

示例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)
开发者ID:AlexHill,项目名称:django-shop,代码行数:25,代码来源:views.py

示例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)
开发者ID:berrym72,项目名称:django-shop,代码行数:8,代码来源:views.py


注:本文中的shop.views.cart.CartDetails.get_context_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。