import pytest from pricing.discounts import apply_discounts def test_no_discounts(): assert apply_discounts(100.0, []) == 100.0 def test_single_discount(): assert apply_discounts(100.0, [25]) == 75.0 def test_single_discount_rounding(): assert apply_discounts(19.99, [15]) == 16.99 def test_stacked_discounts(): # two seasonal discounts stacked on one order assert apply_discounts(100.0, [10, 20]) == 70.0 def test_stacked_same_discount_twice(): assert apply_discounts(100.0, [50, 50]) == 25.0 def test_full_discount_is_allowed(): assert apply_discounts(80.0, [100]) == 0.0 def test_rejects_discount_over_100(): with pytest.raises(ValueError): apply_discounts(100.0, [120]) def test_rejects_negative_discount(): with pytest.raises(ValueError): apply_discounts(100.0, [-5]) def test_rejects_negative_base_price(): with pytest.raises(ValueError): apply_discounts(-10.0, [10])