feat: add ClassifiedAd domain entity
This commit is contained in:
61
tests/test_classified_ad.py
Normal file
61
tests/test_classified_ad.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from decimal import Decimal
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from domain.marketplace.classified_ad import ClassifiedAd
|
||||
|
||||
|
||||
def test_classified_ad_creation():
|
||||
ad_id = uuid4()
|
||||
owner_id = uuid4()
|
||||
|
||||
ad = ClassifiedAd(
|
||||
id=ad_id,
|
||||
_ownerId=owner_id,
|
||||
title="Test Title",
|
||||
text="Test text content",
|
||||
_price=Decimal("99.99"),
|
||||
)
|
||||
|
||||
assert ad.id == ad_id
|
||||
assert ad._ownerId == owner_id
|
||||
assert ad.title == "Test Title"
|
||||
assert ad.text == "Test text content"
|
||||
assert ad._price == Decimal("99.99")
|
||||
|
||||
|
||||
def test_classified_ad_is_immutable():
|
||||
ad = ClassifiedAd(
|
||||
id=uuid4(),
|
||||
_ownerId=uuid4(),
|
||||
title="Title",
|
||||
text="Text",
|
||||
_price=Decimal("10.00"),
|
||||
)
|
||||
|
||||
try:
|
||||
ad.title = "New Title" # type: ignore
|
||||
assert False, "Should have raised FrozenInstanceError"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
def test_classified_ad_equality():
|
||||
ad_id = uuid4()
|
||||
owner_id = uuid4()
|
||||
|
||||
ad1 = ClassifiedAd(
|
||||
id=ad_id,
|
||||
_ownerId=owner_id,
|
||||
title="Title",
|
||||
text="Text",
|
||||
_price=Decimal("10.00"),
|
||||
)
|
||||
ad2 = ClassifiedAd(
|
||||
id=ad_id,
|
||||
_ownerId=owner_id,
|
||||
title="Title",
|
||||
text="Text",
|
||||
_price=Decimal("10.00"),
|
||||
)
|
||||
|
||||
assert ad1 == ad2
|
||||
Reference in New Issue
Block a user