Coverage for src/kwai/modules/identity/user_recoveries/user_recovery_repository.py: 100%

5 statements  

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

1"""Module that defines an interface for a user recovery repository.""" 

2 

3from abc import abstractmethod 

4 

5from kwai.core.domain.value_objects.unique_id import UniqueId 

6from kwai.modules.identity.user_recoveries.user_recovery import UserRecoveryEntity 

7 

8 

9class UserRecoveryRepository: 

10 """Interface for a user recovery repository.""" 

11 

12 @abstractmethod 

13 async def get_by_uuid(self, uuid: UniqueId) -> UserRecoveryEntity: 

14 """Get a user recovery with the given unique id.""" 

15 raise NotImplementedError 

16 

17 @abstractmethod 

18 async def create(self, user_recovery: UserRecoveryEntity) -> UserRecoveryEntity: 

19 """Save a new user recovery.""" 

20 raise NotImplementedError 

21 

22 @abstractmethod 

23 async def update(self, user_recovery: UserRecoveryEntity): 

24 """Save a user recovery.""" 

25 raise NotImplementedError 

26 

27 @abstractmethod 

28 async def delete(self, user_recovery: UserRecoveryEntity): 

29 """Deletes a user recovery.""" 

30 raise NotImplementedError 

31 

32 

33class UserRecoveryNotFoundException(Exception): 

34 """Raised when the user recovery could not be found."""