Example #1
0
 def test_addItemBeforeCalc(self):
     bask = basket.basket()
     bask.addItem("Baked Beans", 4)
     sub, dis, total = bask.calc(catalog=self._cat)
     self.assertEqual(sub, 3.96)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 3.96)
Example #2
0
 def test_negAmount(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(catalog=self._cat,
                                 items={"Baked Beans": -4})
     self.assertEqual(sub, 0)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 0)
Example #3
0
 def test_1itemNoOffer(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(catalog=self._cat,
                                 items={"Baked Beans": 4})
     self.assertEqual(sub, 3.96)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 3.96)
Example #4
0
 def test_negPrice(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(catalog={"Baked Beans": -1},
                                 items={"Baked Beans": 4})
     self.assertEqual(sub, 0)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 0)
Example #5
0
 def test_catNone(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(items={"Baked Beans": 4})
     self.assertEqual(sub, 0)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 0)
     pass
Example #6
0
 def test_clearBasket(self):
     bask = basket.basket()
     bask.addItems({"Baked Beans": 4, "Sardines": 1})
     bask.clearBasket()
     sub, dis, total = bask.calc(catalog=self._cat)
     self.assertEqual(sub, 0)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 0)
Example #7
0
 def test_percentDiscount(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(
         catalog=self._cat,
         offers={"Sardines": [offers.percent(percent=25)]},
         items={"Sardines": 2})
     self.assertEqual(sub, 3.78)
     self.assertEqual(dis, 0.94)
     self.assertEqual(total, 2.84)
Example #8
0
 def test_xforyDiscount(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(
         catalog=self._cat,
         offers={"Baked Beans": [offers.xfory(x=3, y=2)]},
         items={"Baked Beans": 4})
     self.assertEqual(sub, 3.96)
     self.assertEqual(dis, 0.99)
     self.assertEqual(total, 2.97)
Example #9
0
 def test_itemsNoOffer(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(catalog=self._cat,
                                 items={
                                     "Baked Beans": 4,
                                     "Biscuits": 1
                                 })
     self.assertEqual(sub, 5.16)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 5.16)
Example #10
0
 def test_xcheapDiscount(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(
         catalog=self._cat,
         offers={"multi": [offers.buyxGetCheap(amount=3)]},
         items={
             "Shampoo (Small)": 2,
             "Shampoo (Medium)": 1,
             "Shampoo (Large)": 3
         })
     self.assertEqual(sub, 17)
     self.assertEqual(dis, 5.5)
     self.assertEqual(total, 11.5)
Example #11
0
 def test_notInCat(self):
     bask = basket.basket()
     sub, dis, total = bask.calc(catalog=self._cat, items={"Baked": 4})
     self.assertEqual(sub, 0)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 0)
Example #12
0
 def test_allNone(self):
     bask = basket.basket()
     sub, dis, total = bask.calc()
     self.assertEqual(sub, 0)
     self.assertEqual(dis, 0)
     self.assertEqual(total, 0)