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

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

2from abc import ABC, abstractmethod 

3 

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 

7 

8 

9class UserNotFoundException(Exception): 

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

11 

12 

13class UserRepository(ABC): 

14 """A user repository interface.""" 

15 

16 @abstractmethod 

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

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

19 raise NotImplementedError 

20 

21 @abstractmethod 

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

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

24 raise NotImplementedError 

25 

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 

30 

31 @abstractmethod 

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

33 """Update an existing user entity.""" 

34 raise NotImplementedError