refactor: move services to a unit of work over repository ports
Services depend only on src/core/ports: async with self.uow is one transaction, commit is explicit, leaving without it rolls back. A connection is held per step, the JSON routers keep a shared request deadline, and rollback runs under the block deadline. Adds service-tests with fakes, a repo contract run on both the fake and SQL, and make service_test / service_test_db. API, schema and settings are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""Фейки единицы работы, repo и клиентов для быстрых тестов сервисов.
|
||||
|
||||
Метод фейка реализует контракт из докстринга порта (design change
|
||||
`unit-of-work`, решение 11). Совпадение с SQL закрепляет
|
||||
`service-tests/repo_contract.py`, сигнатуры — `unit/test_architecture.py`.
|
||||
"""
|
||||
|
||||
from .clients import (
|
||||
FakeCache,
|
||||
FakeImageRenderer,
|
||||
FakeJobPublisher,
|
||||
FakeObjectStorage,
|
||||
FakeStoredObject,
|
||||
)
|
||||
from .database import FakeDatabase
|
||||
from .repos import (
|
||||
FakeAttachmentJobReplayRepository,
|
||||
FakeAttachmentJobRepository,
|
||||
FakeAttachmentRepository,
|
||||
FakeAttachmentVariantRepository,
|
||||
FakeChatRepository,
|
||||
FakeIdempotencyRepository,
|
||||
FakeMessageRepository,
|
||||
FakeSessionRepository,
|
||||
FakeUserRepository,
|
||||
)
|
||||
from .uow import FakeUnitOfWork
|
||||
|
||||
__all__ = [
|
||||
"FakeAttachmentJobReplayRepository",
|
||||
"FakeAttachmentJobRepository",
|
||||
"FakeAttachmentRepository",
|
||||
"FakeAttachmentVariantRepository",
|
||||
"FakeCache",
|
||||
"FakeChatRepository",
|
||||
"FakeDatabase",
|
||||
"FakeIdempotencyRepository",
|
||||
"FakeImageRenderer",
|
||||
"FakeJobPublisher",
|
||||
"FakeMessageRepository",
|
||||
"FakeObjectStorage",
|
||||
"FakeSessionRepository",
|
||||
"FakeStoredObject",
|
||||
"FakeUnitOfWork",
|
||||
"FakeUserRepository",
|
||||
]
|
||||
Reference in New Issue
Block a user