示例#1
0
 def testCartAddQty(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('tomatoes', 5)
     self.assertEqual(cart.getQty('tomatoes'), 7, "")
示例#2
0
i = IngredientsStore(ingredients)
# v = i.ingredients['tomatoes']
#
# i2 = IngredientsStore.init_from_filepath('../../data/ingredients.csv')
# print i2.ingredients['tomatoes']

#
# try:
#     v2 = i.get_ingredient_price('tomatos')
#     print v2
# except Exception as inst:
#     print type(inst)
#     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