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