Coverage for kwai/modules/portal/applications/application.py: 100%

50 statements  

« prev     ^ index     » next       coverage.py v7.3.0, created at 2023-09-05 17:55 +0000

1"""Module that defines an application entity.""" 

2from kwai.core.domain.entity import Entity 

3from kwai.core.domain.value_objects.identifier import IntIdentifier 

4from kwai.core.domain.value_objects.traceable_time import TraceableTime 

5 

6ApplicationIdentifier = IntIdentifier 

7 

8 

9class ApplicationEntity(Entity[ApplicationIdentifier]): 

10 """An application entity.""" 

11 

12 def __init__( 

13 self, 

14 *, 

15 id_: ApplicationIdentifier | None = None, 

16 title: str, 

17 name: str, 

18 short_description: str, 

19 description: str = "", 

20 remark: str = "", 

21 news: bool = True, 

22 pages: bool = True, 

23 events: bool = True, 

24 weight: int = 0, 

25 traceable_time: TraceableTime | None = None, 

26 ): 

27 """Initialize the application. 

28 

29 Args: 

30 id_: The id of the application entity 

31 title: The title of the application 

32 name: A unique name for the application 

33 short_description: A short description for the application 

34 description: A long description for the application 

35 remark: A remark for the application 

36 news: Can this application contain news? 

37 pages: Can this application contain pages? 

38 events: Can this application contain events? 

39 weight: A weight, can be used to order applications. 

40 traceable_time: The creation and modification timestamp of the application. 

41 """ 

42 super().__init__(id_ or ApplicationIdentifier()) 

43 self._title = title 

44 self._name = name 

45 self._short_description = short_description 

46 self._description = description 

47 self._remark = remark 

48 self._news = news 

49 self._pages = pages 

50 self._events = events 

51 self._weight = weight 

52 self._traceable_time = traceable_time or TraceableTime() 

53 

54 @property 

55 def id(self) -> ApplicationIdentifier: 

56 """Return the id.""" 

57 return self._id 

58 

59 @property 

60 def title(self) -> str: 

61 """Return the title.""" 

62 return self._title 

63 

64 @property 

65 def name(self) -> str: 

66 """Return the name.""" 

67 return self._name 

68 

69 @property 

70 def short_description(self) -> str: 

71 """Return the short description.""" 

72 return self._short_description 

73 

74 @property 

75 def description(self) -> str: 

76 """Return the description.""" 

77 return self._description 

78 

79 @property 

80 def remark(self) -> str: 

81 """Return the remark.""" 

82 return self._remark 

83 

84 @property 

85 def can_contain_news(self) -> bool: 

86 """Return True when the application can contain news.""" 

87 return self._news 

88 

89 @property 

90 def can_contain_pages(self) -> bool: 

91 """Return True when the application can contain pages.""" 

92 return self._pages 

93 

94 @property 

95 def can_contain_events(self) -> bool: 

96 """Return True when the application can contain events.""" 

97 return self._events 

98 

99 @property 

100 def weight(self) -> int: 

101 """Return the weight.""" 

102 return self._weight 

103 

104 @property 

105 def traceable_time(self) -> TraceableTime: 

106 """Return the creation/modification timestamp of this application.""" 

107 return self._traceable_time