Exemplo n.º 1
0
 def total_special_items(self):
     unique_products = {item for item in self.special_items}
     for item in unique_products:
         if item.special_details['specialType'] == 'basic unit discount':
             self.total += specials.basic_unit_discount(self, item.name)
         elif item.special_details['specialType'] == 'buy some get some':
             self.total += specials.buy_some_get_some(self, item.name)
         elif item.special_details['specialType'] == 'buy some for amount':
             self.total += specials.buy_some_for_amount(self, item.name)
 def test_buy_some_get_some__should_buy_three_get_one_free_with_two_extra(
         self, mock_special):
     item_name = 'soda'
     special_details = {
         'specialType': 'buy some get some',
         'buyAmount': 3,
         'getAmount': 1,
         'percentOff': 100,
         'limit': 2
     }
     mock_special.return_value = special_details
     actual = specials.buy_some_get_some(self.cart, item_name)
     assert actual == 7.45
 def test_buy_some_get_some__should_buy_two_get_one_half_off_twice_due_to_limit_of_none(
         self, mock_special):
     item_name = 'soda'
     special_details = {
         'specialType': 'buy some get some',
         'buyAmount': 2,
         'getAmount': 1,
         'percentOff': 50,
         'limit': None
     }
     mock_special.return_value = special_details
     actual = specials.buy_some_get_some(self.cart, item_name)
     assert actual == 7.45