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


Python Cart.get_product_model_path方法代码示例

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


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

示例1: CartTests

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import get_product_model_path [as 别名]

#.........这里部分代码省略.........

        response = self.show_response()

        self.assertContains(response, 'items count: 3')
        self.assertContains(response, 'unique count: 2')

    def test_products_are_removed_all_together(self):
        """
        Can all products of a single type be removed?
        """
        self.cart.add(self.deer, 10.00, 3)
        self.cart.add(self.moose, 20.00, 1)
        self.session.save()

        self.cart.remove(self.deer)

        response = self.show_response()

        self.assertNotContains(response, 'deer')
        self.assertContains(response, 'moose')

    def test_single_product_is_removed(self):
        """
        Can a single instance of a product be removed?
        """
        self.cart.add(self.deer, 10.00, 3)
        self.session.save()

        self.cart.remove_single(self.deer)

        self.assertContains(self.show_response(), '2 deer')

    def test_quantity_is_overwritten(self):
        """
        Can an items quantity be changed?
        """
        self.cart.add(self.deer, 10.00, 3)
        self.session.save()

        self.cart.set_quantity(self.deer, 4)

        self.assertContains(self.show_response(), '4 deer')

    def test_cart_items_are_cleared(self):
        """
        Can a cart be entirely cleared?
        """
        self.cart.add(self.deer, 10.00, 1)
        self.cart.add(self.moose, 20.00, 1)
        self.cart.clear()
        self.session.save()

        response = self.show_response()

        self.assertNotContains(response, 'deer')
        self.assertNotContains(response, 'moose')

    @override_settings(CART_PRODUCT_LOOKUP={'price__gt': 1})
    def test_custom_product_filter_are_applied(self):
        """
        We modify the cart queryset to exclude some products. We
        should not be able to add excluded products to the cart.
        """
        exclude = Product.objects.create(
            name='EXCLUDED',
            price=0.99,
            custom_id=100,
        )

        self.cart.add(self.deer, 10.00, 1)
        self.cart.add(exclude, exclude.price, 1)
        self.session.save()

        response = self.show_response()

        self.assertNotContains(response, 'EXCLUDE')
        self.assertContains(response, 'deer')

    def test_get_model_product_path(self):
        """
        Is a string with the full, correct import path returned for a
        model?
        """
        self.assertEqual(
            self.cart.get_product_model_path(self.deer),
            'carton.tests.models.Product',
        )

    def test_different_product_models(self):
        """
        Does the cart work with different models?
        """
        self.cart.add(self.deer, 10.00, 1)
        self.cart.add(self.ticket, 25.00, 1)
        self.session.save()

        response = self.show_response()

        self.assertContains(response, '1 deer for $10.0')
        self.assertContains(response, '1 Clint Mansell for $25.0')
开发者ID:Matt-Deacalion,项目名称:django-carton,代码行数:104,代码来源:tests.py


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