sw6 testing hands on
This commit is contained in:
1 parent
5d0aa9c876
commit
f089317e86
13 files changed
+314
-2
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
Reference in new issue
Block a user