def test_expiring_price(self):
        product = Product.objects.get(slug='PY-Rocks')
        self.assertEqual(product.unit_price, Decimal("19.50"))

        today = datetime.datetime.now()
        aweek = datetime.timedelta(days=7)
        lastwk = today - aweek
        nextwk = today + aweek

        # new price should override the old one
        price = Price.objects.create(product=product, quantity=Decimal('1'), price=Decimal("10.00"), expires=nextwk)
        self.assertEqual(product.unit_price, Decimal("10.00"))

        # but not if it is expired
        price.expires = lastwk
        price.save()
        self.assertEqual(product.unit_price, Decimal("19.50"))
Test whether a price with an expiration date is used in preference to a non-expiring price.
dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/product/tests.py/ProductTest.test_expiring_price