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

1"""Module that defines an interface for a file upload repository.""" 

2 

3from abc import ABC, abstractmethod 

4 

5from kwai.modules.club.domain.file_upload import FileUploadEntity 

6from kwai.modules.club.domain.member import MemberEntity 

7 

8 

9class DuplicateMemberUploadedException(Exception): 

10 """Raised when the member in current upload is loaded more than once.""" 

11 

12 

13class FileUploadRepository(ABC): 

14 """Interface for an import repository. 

15 

16 An import repository registers file uploads. 

17 """ 

18 

19 @abstractmethod 

20 async def create(self, file_upload: FileUploadEntity) -> FileUploadEntity: 

21 """Save a fileupload. 

22 

23 Args: 

24 file_upload: A fileupload to save. 

25 """ 

26 raise NotImplementedError 

27 

28 @abstractmethod 

29 def is_duplicate(self, member: MemberEntity) -> bool: 

30 """Check if the member was already uploaded with this file upload.""" 

31 

32 @abstractmethod 

33 async def save_member(self, file_upload: FileUploadEntity, member: MemberEntity): 

34 """Save a member imported from the file upload. 

35 

36 Args: 

37 file_upload: The file upload. 

38 member: The member from the file upload. 

39 

40 Raises: 

41 DuplicateMemberUploadedException: if the member in the file upload is 

42 already uploaded. 

43 """ 

44 raise NotImplementedError