feat: added e2e, unit tests and improved tests pipeline

This commit is contained in:
ITQ
2025-11-20 19:39:20 +03:00
parent 4ac902cf3b
commit f93c5a5966
7 changed files with 310 additions and 13 deletions
+36
View File
@@ -0,0 +1,36 @@
from datetime import UTC, datetime
from uuid import UUID, uuid4
import pytest
from template_project.application.common.entity import Entity, to_entity
from template_project.application.common.errors import EntityAlreadyDeletedError
@to_entity
class DummyEntity(Entity[UUID]):
name: str
def test_entity_allows_not_deleted_entities() -> None:
entity = DummyEntity(
id=uuid4(),
created_at=datetime.now(tz=UTC),
name="Alice",
)
entity.ensure_not_deleted()
def test_entity_raise_for_deleted_entities() -> None:
entity = DummyEntity(
id=uuid4(),
created_at=datetime.now(tz=UTC),
deleted_at=datetime.now(tz=UTC),
name="Bob",
)
with pytest.raises(EntityAlreadyDeletedError) as exc_info:
entity.ensure_not_deleted()
assert str(exc_info.value) == "Entity 'DummyEntity' already deleted"