Files
mtusi2026lab5-safronov/src/core/ports/user.py
T
ricoromaandClaude Opus 5.5 6ba74b18f3 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>
2026-10-31 23:14:16 +03:00

34 lines
1.0 KiB
Python

import abc
from collections.abc import Iterable
from uuid import UUID
from src.schemas import dataclasses
class AbstractUserRepository(abc.ABC):
@abc.abstractmethod
async def insert_user(
self,
*,
user: dataclasses.UserFullDTO,
password_hash: str,
) -> dataclasses.UserFullDTO | None:
"""Вставка; `None` — username занят (уникальность держит хранилище,
а не проверка перед вставкой)."""
@abc.abstractmethod
async def get_user_credentials(
self,
*,
username: str,
) -> dataclasses.UserCredentialsDTO | None:
"""Пользователь и хэш пароля; `None` — такого username нет."""
@abc.abstractmethod
async def get_existing_user_ids(
self,
*,
user_ids: Iterable[UUID],
) -> set[UUID]:
"""Те из переданных id, для которых пользователь существует."""