diff --git a/tests/conftest.py b/tests/conftest.py index 145dea7..b48f3c8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,18 +22,20 @@ @pytest.fixture(scope="session") -def uow(): +def uow() -> PocUnitOfWork: bootstrap() return PocUnitOfWork() @pytest.fixture(scope="session") -def message_broker(): +def message_broker() -> RedisMessageBroker: return RedisMessageBroker() @pytest.fixture(scope="session") -def message_bus(uow, example_event_handlers, example_command_handlers): +def message_bus( + uow, example_event_handlers, example_command_handlers +) -> MessageBus: return MessageBus.create( uow=uow, event_handlers=example_event_handlers, @@ -43,60 +45,60 @@ def message_bus(uow, example_event_handlers, example_command_handlers): @pytest.fixture -def base_dir(): - return kingdom_sdk._get_base_dir() # noqa +def base_dir() -> str: + return kingdom_sdk._get_base_dir() @pytest.fixture -def src_dir(): - return kingdom_sdk._get_src_dir() # noqa +def src_dir() -> str: + return kingdom_sdk._get_src_dir() @pytest.fixture -def poc_dir(base_dir): +def poc_dir(base_dir) -> str: return os.path.join(base_dir, "tests/poc/") @pytest.fixture -def query_path(poc_dir): +def query_path(poc_dir) -> str: return os.path.join(poc_dir, "context_example/queries/query.sql") @pytest.fixture -def example_entity(): +def example_entity() -> ExampleEntity: return ExampleEntity.create(name="created") @pytest.fixture -def example_aggregate(example_entity): +def example_aggregate(example_entity) -> ExampleAggregate: return ExampleAggregate.create(value=1.0, reference=example_entity) @pytest.fixture -def example_value_object(): +def example_value_object() -> ExampleVO: return ExampleVO.create(field="immutable") @pytest.fixture -def example_command(): +def example_command() -> CreateExampleAggregate: return CreateExampleAggregate.create(name="raised", value=1.0) @pytest.fixture -def example_unhandlable_command(): +def example_unhandlable_command() -> ExemplifyUnhandlableCommand: return ExemplifyUnhandlableCommand.create() @pytest.fixture(scope="session") -def example_command_handlers(): +def example_command_handlers() -> dict: return {CreateExampleAggregate: MagicMock()} @pytest.fixture -def example_event(): +def example_event() -> ExampleAggregateCreated: return ExampleAggregateCreated.create(id=uuid4(), name="raised") @pytest.fixture(scope="session") -def example_event_handlers(): +def example_event_handlers() -> dict: return {ExampleAggregateCreated: [MagicMock(), MagicMock()]} diff --git a/tests/poc/context_example/bootstrap.py b/tests/poc/context_example/bootstrap.py index 8695950..af33099 100644 --- a/tests/poc/context_example/bootstrap.py +++ b/tests/poc/context_example/bootstrap.py @@ -8,5 +8,5 @@ def bootstrap() -> MetaData: return auto_start_mappers( - os.path.join(kingdom_sdk._get_base_dir(), "tests/poc/") # noqa + os.path.join(kingdom_sdk._get_base_dir(), "tests/poc/") ) diff --git a/tests/poc/context_example/event.py b/tests/poc/context_example/event.py index 3aa987e..8386db7 100644 --- a/tests/poc/context_example/event.py +++ b/tests/poc/context_example/event.py @@ -2,7 +2,6 @@ from dataclasses import dataclass from typing import Any -from uuid import UUID # noqa: F401 from kingdom_sdk.domain.message import Event from kingdom_sdk.utils import time diff --git a/tests/poc/context_example/model.py b/tests/poc/context_example/model.py index ff976a4..af9d662 100644 --- a/tests/poc/context_example/model.py +++ b/tests/poc/context_example/model.py @@ -3,7 +3,7 @@ from dataclasses import dataclass from datetime import datetime from typing import Any -from uuid import uuid4 +from uuid import UUID, uuid4 from kingdom_sdk.domain.aggregate import Aggregate from kingdom_sdk.domain.entity import Entity @@ -17,7 +17,7 @@ class ExampleEntity(Entity): def __init__( self, - id: UUID, # noqa + id: UUID, version: int, is_discarded: bool, registered_at: datetime, @@ -71,7 +71,7 @@ class ExampleAggregate(Aggregate): def __init__( self, - id: UUID, # noqa + id: UUID, version: int, is_discarded: bool, registered_at: datetime, diff --git a/tests/poc/loader_example/my_module.py b/tests/poc/loader_example/my_module.py index 8cee6e3..f469843 100644 --- a/tests/poc/loader_example/my_module.py +++ b/tests/poc/loader_example/my_module.py @@ -1,2 +1,2 @@ -def return_ok(): +def return_ok() -> str: return "It works!"