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


Python Sellable.on_sale_end_date方法代码示例

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


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

示例1: test_price_on_sale_price_setter

# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import on_sale_end_date [as 别名]
    def test_price_on_sale_price_setter(self):
        sellable = Sellable(category=self._category,
                            cost=50,
                            description=u"Test",
                            price=100,
                            store=self.store)
        sellable.on_sale_price = 80

        # - Old promotion
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(2002, 1, 1)
        sellable.price = 10
        self.assertEquals(sellable.base_price, 10)
        self.assertEquals(sellable.on_sale_price, 80)

        # - Future promotion
        sellable.on_sale_start_date = localdate(3001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        sellable.price = 10
        self.assertEquals(sellable.base_price, 10)
        self.assertEquals(sellable.on_sale_price, 80)

        # Current promotion
        sellable.price = 100
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        sellable.price = 10
        self.assertEquals(sellable.base_price, 100)
        self.assertEquals(sellable.on_sale_price, 10)

        sellable.price = -80
        self.assertEquals(sellable.base_price, 100)
        self.assertEquals(sellable.on_sale_price, 0)
开发者ID:pkaislan,项目名称:stoq,代码行数:35,代码来源:test_sellable.py

示例2: test_price_on_sale_price_setter

# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import on_sale_end_date [as 别名]
    def test_price_on_sale_price_setter(self):
        sellable = Sellable(category=self._category,
                            cost=50,
                            description=u"Test",
                            price=100,
                            store=self.store)
        sellable.on_sale_price = 100

        # - Sale period is undefined.
        sellable.on_sale_start_date = None
        sellable.on_sale_end_date = None
        sellable.price = 10
        self.assertEqual(sellable.base_price, 10)
        self.assertEqual(sellable.on_sale_price, 100)

        # - Sale is in the past.
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(2002, 1, 1)
        sellable.price = 20
        self.assertEqual(sellable.base_price, 20)
        self.assertEqual(sellable.on_sale_price, 100)

        # - Sale is in the future.
        sellable.on_sale_start_date = localdate(3001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        sellable.price = 30
        self.assertEqual(sellable.base_price, 30)
        self.assertEqual(sellable.on_sale_price, 100)

        sellable.price = 100
        # - Sale has no start_date but has end_date in the future.
        sellable.on_sale_start_date = None
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        sellable.price = 40
        self.assertEqual(sellable.base_price, 100)
        self.assertEqual(sellable.on_sale_price, 40)

        # - Sale has no end_date but has start_date in the past.
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = None
        sellable.price = 50
        self.assertEqual(sellable.base_price, 100)
        self.assertEqual(sellable.on_sale_price, 50)

        # - Sale is on.
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        sellable.price = 60
        self.assertEqual(sellable.base_price, 100)
        self.assertEqual(sellable.on_sale_price, 60)

        sellable.price = -80
        self.assertEqual(sellable.base_price, 100)
        self.assertEqual(sellable.on_sale_price, 0)
开发者ID:hackedbellini,项目名称:stoq,代码行数:56,代码来源:test_sellable.py

示例3: test_price_on_sale_price_getter

# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import on_sale_end_date [as 别名]
    def test_price_on_sale_price_getter(self):
        sellable = Sellable(category=self._category,
                            cost=50,
                            description=u"Test",
                            price=100,
                            store=self.store)

        # - Sale period is undefined.
        sellable.on_sale_start_date = None
        sellable.on_sale_end_date = None
        self.assertEqual(sellable.price, 100)
        sellable.on_sale_price = 80
        self.assertEqual(sellable.price, 100)

        # - Sale has no start_date but has end_date in the future.
        sellable.on_sale_start_date = None
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        self.assertEqual(sellable.price, 80)

        # - Sale has no end_date but has start_date in the past.
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = None
        self.assertEqual(sellable.price, 80)

        # - Sale is in the past.
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(2002, 1, 1)
        self.assertEqual(sellable.price, 100)

        # - Sale is in the future.
        sellable.on_sale_start_date = localdate(3001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        self.assertEqual(sellable.price, 100)

        # - Sale is on (for a long time, by the way).
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        self.assertEqual(sellable.price, 80)
开发者ID:hackedbellini,项目名称:stoq,代码行数:40,代码来源:test_sellable.py


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