def make_tiers(carrier, prices, expires=None): for min_total, price in prices: t = WeightTier(carrier=carrier, min_total=Decimal("%i.00" % min_total), price=Decimal("%i.00" % price), expires=expires) t.save()
def setUp(self): self.carrier = Carrier(name="pricing", active=True) self.carrier.save() t = WeightTier( carrier=self.carrier, min_total=Decimal("0.00"), price=Decimal("10.00") ) t.save()
def testCreate(self): c = Carrier(key="test", active=True) c.save() t = WeightTier(carrier=c, min_total=Decimal("0.00"), price=Decimal("10.00")) t.save() self.assertEqual(c.price(Decimal("0.00")), Decimal("10.00"))
def test2Prices(self): t = WeightTier( carrier=self.carrier, min_total=Decimal("20.00"), price=Decimal("15.00") ) t.save() self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00")) self.assertEqual(self.carrier.price(Decimal("20.00")), Decimal("15.00"))
def make_tiers(carrier, prices, expires=None): for min_total, price in prices: t = WeightTier( carrier=carrier, min_total=Decimal("%i.00" % min_total), price=Decimal("%i.00" % price), expires=expires ) t.save()