def test_multibuy_eight_item_buy_5_2_free(self): '''Correct line total for item with 8 quantity (buy 5 get 2 free).''' product_store = self._create_product_store() multibuy_apples = MultiBuyOffer('apple', 5, 2) cartitem = CartItem('apple', 8) self.assertEqual(multibuy_apples.calculate_line_total( cartitem, product_store), Decimal('0.90'))
def test_multibuy_seven_item_buy_2_1_free(self): '''Correct line total for item with 7 quantity (buy 2 get 1 free).''' product_store = self._create_product_store() multibuy_apples = MultiBuyOffer('apple', 2, 1) cartitem = CartItem('apple', 7) self.assertEqual(multibuy_apples.calculate_line_total( cartitem, product_store), Decimal('0.75'))
def test_bogof_one_item_six_quantity(self): '''Correct line total for item with 6 quantity.''' product_store = self._create_product_store() bogof_apples = MultiBuyOffer('apple', 1, 1) cartitem = CartItem('apple', 6) self.assertEqual(bogof_apples.calculate_line_total( cartitem, product_store), Decimal('0.45'))
def test_bogof_one_item_six_quantity(self): '''Correct line total for item with 6 quantity.''' product_store = self._create_product_store() bogof_apples = MultiBuyOffer('apple', 1, 1) cartitem = CartItem('apple', 6) self.assertEqual( round(bogof_apples.calculate_line_total(cartitem, product_store), 2), float('0.45'))
def test_bogof_one_item_two_quantity(self): """ Buy one get one free correct line total for item with 2 quantity. """ product_store = self._create_product_store() bogof_blueberries = MultiBuyOffer("blueberries", 1, 1) basketitem = BasketItem("blueberries", 2) self.assertEqual(bogof_blueberries.calculate_line_total(basketitem, product_store), Decimal("2.00"))
def test_multibuy_one_item_buy_2_1_free(self): """ Buy two get one free correct line total for item with 1 quantity. """ product_store = self._create_product_store() bogof_blueberries = MultiBuyOffer("blueberries", 2, 1) basketitem = BasketItem("blueberries") self.assertEqual(bogof_blueberries.calculate_line_total(basketitem, product_store), Decimal("2.00"))
def test_multibuy_eight_item_buy_5_2_free(self): '''Correct line total for item with 8 quantity (buy 5 get 2 free).''' product_store = self._create_product_store() multibuy_apples = MultiBuyOffer('apple', 5, 2) cartitem = CartItem('apple', 8) self.assertEqual( multibuy_apples.calculate_line_total(cartitem, product_store), Decimal('0.90'))
def test_multibuy_seven_item_buy_2_1_free(self): '''Correct line total for item with 7 quantity (buy 2 get 1 free).''' product_store = self._create_product_store() multibuy_apples = MultiBuyOffer('apple', 2, 1) cartitem = CartItem('apple', 7) self.assertEqual( multibuy_apples.calculate_line_total(cartitem, product_store), Decimal('0.75'))
def test_bogof_one_item_five_quantity(self): '''Correct line total for item with 5 quantity.''' product_store = self._create_product_store() bogof_apples = MultiBuyOffer('apple', 1, 1) cartitem = CartItem('apple', 5) self.assertEqual( bogof_apples.calculate_line_total(cartitem, product_store), Decimal('0.45'))
def test_multibuy_seven_item_buy_5_2_free(self): '''Correct line total for item with 7 quantity (buy 5 get 2 free).''' product_store = self._create_product_store() multibuy_apples = MultiBuyOffer('apple', 5, 2) cartitem = CartItem('apple', 7) self.assertEqual( round( multibuy_apples.calculate_line_total(cartitem, product_store), 2), float('0.75'))
def test_multibuy_six_item_buy_2_1_free(self): '''Correct line total for item with 6 quantity (buy 2 get 1 free).''' product_store = self._create_product_store() multibuy_apples = MultiBuyOffer('apple', 2, 1) cartitem = CartItem('apple', 6) self.assertEqual( round( multibuy_apples.calculate_line_total(cartitem, product_store), 2), float('0.60'))