Coverage for src/kwai/modules/club/domain/file_upload.py: 100%
33 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 a file upload entity."""
3from kwai.core.domain.entity import Entity
4from kwai.core.domain.value_objects.identifier import IntIdentifier
5from kwai.core.domain.value_objects.owner import Owner
6from kwai.core.domain.value_objects.traceable_time import TraceableTime
7from kwai.core.domain.value_objects.unique_id import UniqueId
10FileUploadIdentifier = IntIdentifier
13class FileUploadEntity(Entity[FileUploadIdentifier]):
14 """An FileUploadEntity keeps information about a file upload."""
16 def __init__(
17 self,
18 *,
19 id_: FileUploadIdentifier | None = None,
20 uuid: UniqueId | None = None,
21 filename: str,
22 owner: Owner,
23 remark: str = "",
24 preview: bool = False,
25 traceable_time: TraceableTime | None = None,
26 ):
27 """Initialize a file upload entity.
29 Args:
30 id_: The id of the upload.
31 uuid: The unique id of the upload.
32 filename: The name of the file.
33 owner: The user who uploaded the file.
34 remark: A remark about the upload.
35 preview: Whether the upload is a preview.
36 traceable_time: The creation and modification timestamp of the upload.
37 """
38 super().__init__(id_ or FileUploadIdentifier())
39 self._uuid = uuid or UniqueId.generate()
40 self._filename = filename
41 self._owner = owner
42 self._remark = remark
43 self._preview = preview
44 self._traceable_time = traceable_time or TraceableTime()
46 @property
47 def filename(self) -> str:
48 """Return the filename."""
49 return self._filename
51 @property
52 def remark(self) -> str:
53 """Return the remark."""
54 return self._remark
56 @property
57 def owner(self) -> Owner:
58 """Return the owner."""
59 return self._owner
61 @property
62 def uuid(self) -> UniqueId:
63 """Return the uuid."""
64 return self._uuid
66 @property
67 def preview(self) -> bool:
68 """Return the preview."""
69 return self._preview
71 @property
72 def traceable_time(self) -> TraceableTime:
73 """Return the creation/modification time."""
74 return self._traceable_time