Coverage for src/kwai/modules/identity/users/user_repository.py: 100%
6 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that defines the interface for a user repository."""
3from abc import ABC, abstractmethod
5from kwai.core.domain.value_objects.email_address import EmailAddress
6from kwai.core.domain.value_objects.unique_id import UniqueId
7from kwai.modules.identity.users.user import UserEntity, UserIdentifier
10class UserNotFoundException(Exception):
11 """Raised when a user could not be found."""
14class UserRepository(ABC):
15 """A user repository interface."""
17 @abstractmethod
18 async def get_user_by_id(self, id_: UserIdentifier) -> UserEntity:
19 """Get a user using the id."""
20 raise NotImplementedError
22 @abstractmethod
23 async def get_user_by_uuid(self, uuid: UniqueId) -> UserEntity:
24 """Get a user using the unique id."""
25 raise NotImplementedError
27 @abstractmethod
28 async def get_user_by_email(self, email: EmailAddress) -> UserEntity:
29 """Get a user using his/her email address."""
30 raise NotImplementedError
32 @abstractmethod
33 async def update(self, user: UserEntity) -> None:
34 """Update an existing user entity."""
35 raise NotImplementedError