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


Python CheckoutSelectionView.create_order_object_from_cart方法代码示例

本文整理汇总了Python中shop.views.checkout.CheckoutSelectionView.create_order_object_from_cart方法的典型用法代码示例。如果您正苦于以下问题:Python CheckoutSelectionView.create_order_object_from_cart方法的具体用法?Python CheckoutSelectionView.create_order_object_from_cart怎么用?Python CheckoutSelectionView.create_order_object_from_cart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shop.views.checkout.CheckoutSelectionView的用法示例。


在下文中一共展示了CheckoutSelectionView.create_order_object_from_cart方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_orders_are_created_and_cleaned_up

# 需要导入模块: from shop.views.checkout import CheckoutSelectionView [as 别名]
# 或者: from shop.views.checkout.CheckoutSelectionView import create_order_object_from_cart [as 别名]
 def test_orders_are_created_and_cleaned_up(self):
     view = CheckoutSelectionView(request=self.request)
     # create a new order with pk 1
     old_order = view.create_order_object_from_cart()
     # create order with pk 2 so sqlite doesn't reuse pk 1
     Order.objects.create()
     # then create a different new order, from a different cart with pk 3
     # order pk 1 should be deleted here
     self.cart.add_product(self.product)
     new_order = view.create_order_object_from_cart()
     self.assertFalse(Order.objects.filter(pk=old_order.pk).exists()) # check it was deleted
     self.assertNotEqual(old_order.order_total, new_order.order_total)
开发者ID:albeirochoa,项目名称:django-shop,代码行数:14,代码来源:views_checkout.py

示例2: test_processing_signal

# 需要导入模块: from shop.views.checkout import CheckoutSelectionView [as 别名]
# 或者: from shop.views.checkout.CheckoutSelectionView import create_order_object_from_cart [as 别名]
    def test_processing_signal(self):
        view = CheckoutSelectionView(request=self.request)

        order_from_signal = []
        def receiver(sender, order=None, **kwargs):
            order_from_signal.append(order)

        processing.connect(receiver)
        res = view.create_order_object_from_cart()

        self.assertIs(res, order_from_signal[0])
开发者ID:albeirochoa,项目名称:django-shop,代码行数:13,代码来源:views_checkout.py

示例3: test_order_added_to_session_if_no_user

# 需要导入模块: from shop.views.checkout import CheckoutSelectionView [as 别名]
# 或者: from shop.views.checkout.CheckoutSelectionView import create_order_object_from_cart [as 别名]
 def test_order_added_to_session_if_no_user(self):
     """
     Check that the order_id is saved on the session if
     no user is available.
     """
     setattr(self.request, 'user', None)
     self.request.session["cart_id"] = self.cart.pk
     view = CheckoutSelectionView(request=self.request)
     order = view.create_order_object_from_cart()
     self.assertEquals(self.request.session.get("order_id"), order.pk)
     setattr(self.request, 'user', self.user)
开发者ID:evandempsey,项目名称:django-shop,代码行数:13,代码来源:views_checkout.py

示例4: test_save_extra_info_to_order

# 需要导入模块: from shop.views.checkout import CheckoutSelectionView [as 别名]
# 或者: from shop.views.checkout.CheckoutSelectionView import create_order_object_from_cart [as 别名]
    def test_save_extra_info_to_order(self):
        """
        Check that extra info associated with the order is saved.
        """
        # Set the request to a POST and add data for the form to parse.
        setattr(self.request, 'method', 'POST')
        setattr(self.request, 'POST', {"text": "blah blah"})

        view = CheckoutSelectionView(request=self.request)
        form = view.get_extra_info_form()
        self.assertTrue(form.is_valid())
        order = view.create_order_object_from_cart()
        view.save_extra_info_to_order(order, form)
        self.assertTrue(OrderExtraInfo.objects.filter(order=order).exists())

        # Set the request back to how it was in setUp()
        setattr(self.request, 'method', 'GET')
        del self.request.POST
开发者ID:evandempsey,项目名称:django-shop,代码行数:20,代码来源:views_checkout.py

示例5: test_order_created

# 需要导入模块: from shop.views.checkout import CheckoutSelectionView [as 别名]
# 或者: from shop.views.checkout.CheckoutSelectionView import create_order_object_from_cart [as 别名]
 def test_order_created(self):
     view = CheckoutSelectionView(request=self.request)
     res = view.create_order_object_from_cart()
     self.assertEqual(res.order_total, Decimal('0'))
开发者ID:albeirochoa,项目名称:django-shop,代码行数:6,代码来源:views_checkout.py


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