You've already forked RekomenciBackend
feat: added e2e, unit tests and improved tests pipeline
This commit is contained in:
@@ -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"
|
||||
Reference in New Issue
Block a user