Files
python-fun/tests/test_money.py

25 lines
578 B
Python

from decimal import Decimal
from domain.marketplace.money import Money
def test_money_creation():
money = Money(amount=Decimal("99.99"))
assert money.amount == Decimal("99.99")
def test_money_is_immutable():
money = Money(amount=Decimal("10.00"))
try:
money.amount = Decimal("20.00") # type: ignore
assert False, "Should have raised FrozenInstanceError"
except AttributeError:
pass
def test_money_equality():
money1 = Money(amount=Decimal("50.00"))
money2 = Money(amount=Decimal("50.00"))
assert money1 == money2