示例#1
0
 def testGetTotalNoDiscount(self):
     ingredients_list = [
         ('tomatoes', Decimal('0.15')),
         ('chicken', Decimal('3.49')),
         ('onions', Decimal('2.00')),
         ('rice', Decimal('0.70')),
     ]
     ingrStoreInst = IngredientsStore(ingredients_list)
     cart = Cart(ingrStoreInst)
     cart.add('tomatoes', 2)
     cart.add('onions', 4)
     cart.add('chicken',2)
     cart.add('rice',3)
     self.assertEqual(Decimal('17.38').compare(cart.get_total()), 0, "")
示例#2
0
 def testGetTotalWithDiscounts(self):
     ingredients_list = [
         ('tomatoes', Decimal('0.15')),
         ('chicken', Decimal('3.49')),
         ('onions', Decimal('2.00')),
         ('rice', Decimal('0.70')),
     ]
     ingrStoreInst = IngredientsStore(ingredients_list)
     
     cart = Cart(ingrStoreInst)
     cart.add('tomatoes', 7)
     cart.add('onions', 4)
     cart.add('chicken',2)
     cart.add('rice',3)
     
     d1 = BulkDiscount('tomatoes',2,1)
     d2 = BulkDiscount ('onions',1,1)
     d3 = NoDiscount('rice')
     
     self.assertEqual(Decimal('13.83').compare(cart.get_total([d1,d2])),0,"")
示例#3
0
#     print inst.args

c = Cart(i)
q = c.getQty('tomatoes')
print q
c.add('tomatoes', 2)
q = c.getQty('tomatoes')
print q
c.add('tomatoes', 4)
q = c.getQty('tomatoes')
print q

d = BulkDiscount('tomatoes', 2, 1)
d1 = NoDiscount('tomatoes')
v = d.calc_line_total(c)
print v
v1 = d1.calc_line_total(c)
print v1

dic = dict()
dic = {"1": 1, "2": 2}
print dic
k = map(lambda (k, v): v * v, dic.iteritems())
print k
c.add('onions', 3)
#t = c.get_total()
#print t

t1 = c.get_total([d])
print t1