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
« 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."""
3from abc import ABC, abstractmethod
5from kwai.core.domain.value_objects.unique_id import UniqueId
6from kwai.modules.portal.domain.author import AuthorEntity, AuthorIdentifier
9class AuthorNotFoundException(Exception):
10 """Raised when an author cannot be found."""
13class AuthorRepository(ABC):
14 """An interface for an author repository."""
16 @abstractmethod
17 async def get(self, id: AuthorIdentifier) -> AuthorEntity:
18 """Get the author with the given user identifier."""
19 raise NotImplementedError
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
26 @abstractmethod
27 async def create(self, author: AuthorEntity) -> AuthorEntity:
28 """Save an author entity to the database."""
29 raise NotImplementedError
31 @abstractmethod
32 async def delete(self, author: AuthorEntity) -> None:
33 """Delete an author entity from the dabase."""
34 raise NotImplementedError