29 lines
699 B
Python
29 lines
699 B
Python
import pytest
|
|
|
|
from src.exercises.pricing import discount_price
|
|
|
|
|
|
def test_discount_price_happy_path():
|
|
result = discount_price(100.0, 20.0)
|
|
assert result == 80.0
|
|
|
|
|
|
def test_discount_price_edge_case_1():
|
|
result = discount_price(100.0, 100.0)
|
|
assert result == 0.0
|
|
|
|
|
|
def test_discount_price_edge_case_2():
|
|
result = discount_price(100.0, 0.0)
|
|
assert result == 100.0
|
|
|
|
|
|
def test_discount_price_negative_price():
|
|
with pytest.raises(ValueError, match="price cannot be negative"):
|
|
discount_price(-1.0, 20.0)
|
|
|
|
|
|
def test_discount_price_invalid_discount():
|
|
with pytest.raises(ValueError, match="discount must be between 0 and 100"):
|
|
discount_price(100.0, 120.0)
|