feat(): unit tests for domain entities and basic invariants

This commit is contained in:
gitgernit
2025-11-23 09:34:09 +03:00
parent 25b35a3ccd
commit fbceb9fefe
9 changed files with 541 additions and 12 deletions
+44
View File
@@ -0,0 +1,44 @@
from datetime import UTC
from uuid import UUID, uuid4
from template_project.application.user.entity import UserId
from template_project.application.user.profile.entity import Profile
def test_profile_factory_creates_valid_profile() -> None:
user_id = UserId(uuid4())
profile = Profile.factory(
user_id=user_id,
email="test@example.com",
display_name="Test User",
first_name="Test",
last_name="User",
avatar_url="https://example.com/avatar.jpg",
phone="+1234567890",
)
assert isinstance(profile.id, UUID)
assert profile.user_id == user_id
assert profile.email == "test@example.com"
assert profile.display_name == "Test User"
assert profile.first_name == "Test"
assert profile.last_name == "User"
assert profile.avatar_url == "https://example.com/avatar.jpg"
assert profile.phone == "+1234567890"
assert profile.deleted_at is None
assert profile.created_at.tzinfo == UTC
def test_profile_factory_with_minimal_fields() -> None:
user_id = UserId(uuid4())
profile = Profile.factory(user_id=user_id)
assert profile.user_id == user_id
assert profile.email is None
assert profile.display_name is None
assert profile.first_name is None
assert profile.last_name is None
assert profile.avatar_url is None
assert profile.phone is None