First commit

This commit is contained in:
2026-07-06 06:00:10 +06:00
commit 68696fa4d2
32 changed files with 1085 additions and 0 deletions

View File

@ -0,0 +1,43 @@
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])