def test_add_adjustment(self): sale = Sale("product", value=10, amount=3) sale.add_adjustment("subtract", 40) expected_list = [ sale.Adjustment(operation="subtract", adjusted_amount=40) ] actual_list = sale.adjustments self.assertListEqual(expected_list, actual_list)
def test_apply_adjustments_add(self): sale = Sale("product", value=100, amount=2) sale.add_adjustment("add", 40) expected_value = 140 expected_total_value = 280 sale.apply_adjustments() self.assertEqual(expected_value, sale.value) self.assertEqual(expected_total_value, sale.total_value)
def test_apply_adjustments_mul(self): sale = Sale("product", value=2, amount=2) sale.add_adjustment("multiply", 3) expected_value = 6 expected_total_value = 12 sale.apply_adjustments() self.assertEqual(expected_value, sale.value) self.assertEqual(expected_total_value, sale.total_value)
def test_apply_adjustments_sub(self): sale = Sale("product", value=10, amount=3) sale.add_adjustment("subtract", 40) expected_value = -30 expected_total_value = -90 sale.apply_adjustments() self.assertEqual(expected_value, sale.value) self.assertEqual(expected_total_value, sale.total_value)