Coverage for src/kwai/modules/portal/repositories/author_repository.py: 100%

5 statements  

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

1"""Module that defines an interface for an Author repository.""" 

2 

3from abc import ABC, abstractmethod 

4 

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

6from kwai.modules.portal.domain.author import AuthorEntity, AuthorIdentifier 

7 

8 

9class AuthorNotFoundException(Exception): 

10 """Raised when an author cannot be found.""" 

11 

12 

13class AuthorRepository(ABC): 

14 """An interface for an author repository.""" 

15 

16 @abstractmethod 

17 async def get(self, id: AuthorIdentifier) -> AuthorEntity: 

18 """Get the author with the given user identifier.""" 

19 raise NotImplementedError 

20 

21 @abstractmethod 

22 async def get_by_uuid(self, uuid: UniqueId) -> AuthorEntity: 

23 """Get the author that is linked to the user with the given uuid.""" 

24 raise NotImplementedError 

25 

26 @abstractmethod 

27 async def create(self, author: AuthorEntity) -> AuthorEntity: 

28 """Save an author entity to the database.""" 

29 raise NotImplementedError 

30 

31 @abstractmethod 

32 async def delete(self, author: AuthorEntity) -> None: 

33 """Delete an author entity from the dabase.""" 

34 raise NotImplementedError