コード例 #1
0
    def get_schema(self, name):
        """Get schema by name.

        :param name: Name of schema.
        :type name: str
        """
        from collective.behavior.discount.interfaces import IDiscount
        return IDiscount.get(name)
コード例 #2
0
    def test_discount_available(self):
        article1 = self.create_content(
            "collective.cart.core.Article", title="Ärticle1", sku="SKÖ1", money=self.money("12.40"), vat_rate=24.0
        )
        adapter = IArticleAdapter(article1)
        self.assertFalse(adapter.discount_available())

        from collective.behavior.discount.interfaces import IDiscount

        discount = IDiscount(article1)
        discount.discount_enabled = True
        self.assertFalse(adapter.discount_available())

        from datetime import date

        today = date.today()
        from datetime import timedelta

        discount.discount_end = today - timedelta(1)
        self.assertFalse(adapter.discount_available())

        discount.discount_end = today + timedelta(1)
        self.assertTrue(adapter.discount_available())

        article1.discount_end = None
        discount.discount_start = today + timedelta(1)
        self.assertFalse(adapter.discount_available())

        discount.discount_start = today - timedelta(1)
        self.assertTrue(adapter.discount_available())

        discount.discount_end = today - timedelta(1)
        self.assertFalse(adapter.discount_available())

        discount.discount_end = today + timedelta(1)
        self.assertTrue(adapter.discount_available())

        discount.discount_start = today + timedelta(1)
        self.assertFalse(adapter.discount_available())
コード例 #3
0
 def test_instance_provides_IDiscount(self):
     instance = self.create_instance()
     from collective.behavior.discount.interfaces import IDiscount
     self.assertTrue(IDiscount.providedBy(instance))