Coverage for src/kwai/modules/club/repositories/file_upload_repository.py: 100%
5 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that defines an interface for a file upload repository."""
3from abc import ABC, abstractmethod
5from kwai.modules.club.domain.file_upload import FileUploadEntity
6from kwai.modules.club.domain.member import MemberEntity
9class DuplicateMemberUploadedException(Exception):
10 """Raised when the member in current upload is loaded more than once."""
13class FileUploadRepository(ABC):
14 """Interface for an import repository.
16 An import repository registers file uploads.
17 """
19 @abstractmethod
20 async def create(self, file_upload: FileUploadEntity) -> FileUploadEntity:
21 """Save a fileupload.
23 Args:
24 file_upload: A fileupload to save.
25 """
26 raise NotImplementedError
28 @abstractmethod
29 def is_duplicate(self, member: MemberEntity) -> bool:
30 """Check if the member was already uploaded with this file upload."""
32 @abstractmethod
33 async def save_member(self, file_upload: FileUploadEntity, member: MemberEntity):
34 """Save a member imported from the file upload.
36 Args:
37 file_upload: The file upload.
38 member: The member from the file upload.
40 Raises:
41 DuplicateMemberUploadedException: if the member in the file upload is
42 already uploaded.
43 """
44 raise NotImplementedError