Coverage for bc/kwai-bc-identity/src/kwai_bc_identity/users/user_repository.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2024-01-01 00:00 +0000

1"""Module that defines the interface for a user repository.""" 

2 

3from abc import ABC, abstractmethod 

4 

5from kwai_core.domain.value_objects.email_address import EmailAddress 

6from kwai_core.domain.value_objects.unique_id import UniqueId 

7 

8from kwai_bc_identity.users.user import UserEntity, UserIdentifier 

9 

10 

11class UserNotFoundException(Exception): 

12 """Raised when a user could not be found.""" 

13 

14 

15class UserRepository(ABC): 

16 """A user repository interface.""" 

17 

18 @abstractmethod 

19 async def get_user_by_id(self, id_: UserIdentifier) -> UserEntity: 

20 """Get a user using the id.""" 

21 raise NotImplementedError 

22 

23 @abstractmethod 

24 async def get_user_by_uuid(self, uuid: UniqueId) -> UserEntity: 

25 """Get a user using the unique id.""" 

26 raise NotImplementedError 

27 

28 @abstractmethod 

29 async def get_user_by_email(self, email: EmailAddress) -> UserEntity: 

30 """Get a user using his/her email address.""" 

31 raise NotImplementedError 

32 

33 @abstractmethod 

34 async def update(self, user: UserEntity) -> None: 

35 """Update an existing user entity.""" 

36 raise NotImplementedError