hermes-code-demo/tests/test_discount.py

27 lines
585 B
Python
Raw Normal View History

"""Regression tests for the demo pricing helper."""
import pytest
from src.discount import apply_discount
def test_no_discount_returns_subtotal() -> None:
assert apply_discount(100.0, 0) == 100.0
def test_ten_percent_off() -> None:
assert apply_discount(100.0, 10) == 90.0
def test_full_discount_is_free() -> None:
assert apply_discount(59.99, 100) == 0.0
def test_fractional_rounding() -> None:
assert apply_discount(19.99, 15) == 16.99
def test_rejects_out_of_range_percent() -> None:
with pytest.raises(ValueError):
apply_discount(10.0, 101)