32 lines
709 B
Python
32 lines
709 B
Python
from decimal import Decimal
|
|
|
|
import pytest
|
|
|
|
from domain.marketplace.price import Price
|
|
|
|
|
|
def test_price_creation():
|
|
price = Price(amount=Decimal("99.99"))
|
|
assert price.amount == Decimal("99.99")
|
|
|
|
|
|
def test_price_is_immutable():
|
|
price = Price(amount=Decimal("10.00"))
|
|
|
|
try:
|
|
price.amount = Decimal("20.00") # type: ignore
|
|
assert False, "Should have raised FrozenInstanceError"
|
|
except AttributeError:
|
|
pass
|
|
|
|
|
|
def test_price_can_not_be_negative():
|
|
with pytest.raises(ValueError):
|
|
Price(amount=Decimal("-10.00"))
|
|
|
|
|
|
def test_price_equality():
|
|
price1 = Price(amount=Decimal("50.00"))
|
|
price2 = Price(amount=Decimal("50.00"))
|
|
assert price1 == price2
|