Coverage for kwai/modules/identity/users/user_account_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 a repository for a user account."""
2from abc import abstractmethod
4from kwai.core.domain.value_objects.email_address import EmailAddress
5from kwai.modules.identity.users.user_account import UserAccountEntity
8class UserAccountRepository:
9 """Interface for a user account repository."""
11 @abstractmethod
12 async def get_user_by_email(self, email: EmailAddress) -> UserAccountEntity:
13 """Get a user account with the given email address."""
14 raise NotImplementedError
16 async def exists_with_email(self, email: EmailAddress) -> bool:
17 """Check if a user account with the given email address already exists.
19 Args:
20 email: The email address to check.
22 Returns:
23 True when a user with the given email address exists.
24 """
25 raise NotImplementedError
27 @abstractmethod
28 async def create(self, user_account: UserAccountEntity) -> UserAccountEntity:
29 """Save a new user account."""
30 raise NotImplementedError
32 @abstractmethod
33 async def update(self, user_account: UserAccountEntity):
34 """Save a user account."""
35 raise NotImplementedError
37 @abstractmethod
38 async def delete(self, user_account):
39 """Delete a user account."""
40 raise NotImplementedError
43class UserAccountNotFoundException(Exception):
44 """Raised when a user account cannot be found."""