feat: make ClassifiedAd._price optional with default 0.00
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from decimal import Decimal
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from domain.marketplace.classified_ad import ClassifiedAd
|
||||
from domain.marketplace.user_id import UserId
|
||||
|
||||
@@ -24,6 +26,41 @@ def test_classified_ad_creation():
|
||||
assert ad._price == Decimal("99.99")
|
||||
|
||||
|
||||
def test_classified_ad_can_not_be_created_without_id():
|
||||
with pytest.raises(TypeError):
|
||||
ad = ClassifiedAd(
|
||||
_ownerId=UserId(value=uuid4()),
|
||||
title="Title",
|
||||
text="Text",
|
||||
_price=Decimal("10.00"),
|
||||
)
|
||||
|
||||
def test_classified_ad_can_not_be_created_without_owner_id():
|
||||
with pytest.raises(TypeError):
|
||||
ad = ClassifiedAd(
|
||||
id=UserId(value=uuid4()),
|
||||
title="Title",
|
||||
text="Text",
|
||||
_price=Decimal("10.00"),
|
||||
)
|
||||
|
||||
def test_classified_ad_can_be_created_without_price():
|
||||
ad_id = uuid4()
|
||||
owner_id = UserId(value=uuid4())
|
||||
|
||||
ad = ClassifiedAd(
|
||||
id=ad_id,
|
||||
_ownerId=owner_id,
|
||||
title="Test Title",
|
||||
text="Test text content",
|
||||
)
|
||||
|
||||
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("0.00")
|
||||
|
||||
def test_classified_ad_is_immutable():
|
||||
ad = ClassifiedAd(
|
||||
id=uuid4(),
|
||||
|
||||
Reference in New Issue
Block a user