feat: add Money value object
This commit is contained in:
24
tests/test_money.py
Normal file
24
tests/test_money.py
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
Reference in New Issue
Block a user