Coverage for src/kwai/modules/training/trainings/training.py: 100%

56 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2024-01-01 00:00 +0000

1"""Module for defining a training entity.""" 

2 

3from kwai.core.domain.entity import Entity 

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

5from kwai.core.domain.value_objects.period import Period 

6from kwai.core.domain.value_objects.text import LocaleText 

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

8from kwai.modules.training.teams.team import TeamEntity 

9from kwai.modules.training.trainings.training_definition import ( 

10 TrainingDefinitionEntity, 

11) 

12from kwai.modules.training.trainings.value_objects import TrainingCoach 

13 

14 

15TrainingIdentifier = IntIdentifier 

16 

17 

18class TrainingEntity(Entity[TrainingIdentifier]): 

19 """A training entity.""" 

20 

21 def __init__( 

22 self, 

23 *, 

24 id_: TrainingIdentifier | None = None, 

25 texts: list[LocaleText], 

26 definition: TrainingDefinitionEntity | None = None, 

27 coaches: list[TrainingCoach] | None = None, 

28 teams: list[TeamEntity] | None = None, 

29 season: None = None, 

30 period: Period, 

31 active: bool = True, 

32 cancelled: bool = False, 

33 location: str = "", 

34 remark: str = "", 

35 traceable_time: TraceableTime | None = None, 

36 ): 

37 """Initialize a training. 

38 

39 Args: 

40 id_: The id of the training 

41 texts: A list with text content 

42 definition: The related definition, when the training was created from a 

43 definition. 

44 coaches: A list of assigned coaches. 

45 teams: A list of assigned teams. 

46 period: The period of the training. 

47 season: The season that the training belongs to (not supported yet). 

48 active: Is this training active? 

49 cancelled: Is this training cancelled? 

50 location: The location of this training 

51 remark: A remark about this training 

52 traceable_time: The creation and modification timestamp of the training. 

53 """ 

54 super().__init__(id_ or TrainingIdentifier()) 

55 self._texts = texts 

56 self._definition = definition 

57 self._coaches = coaches or [] 

58 self._teams = teams or [] 

59 self._season = season 

60 self._period = period 

61 self._active = active 

62 self._cancelled = cancelled 

63 self._location = location 

64 self._remark = remark 

65 self._traceable_time = traceable_time or TraceableTime() 

66 

67 @property 

68 def id(self) -> TrainingIdentifier: 

69 """Return the id of the training.""" 

70 return self._id 

71 

72 @property 

73 def definition(self) -> TrainingDefinitionEntity | None: 

74 """Return the related training definition.""" 

75 return self._definition 

76 

77 @property 

78 def texts(self) -> list[LocaleText]: 

79 """Return the text content of a training. 

80 

81 Remark: 

82 The list is a copy. 

83 """ 

84 return self._texts.copy() 

85 

86 @property 

87 def coaches(self) -> list[TrainingCoach]: 

88 """Return the coaches attached to the training. 

89 

90 Remark: 

91 The list is a copy 

92 """ 

93 return self._coaches.copy() 

94 

95 @property 

96 def teams(self) -> list[TeamEntity]: 

97 """Return the teams of the training. 

98 

99 Remark: 

100 The list is a copy 

101 """ 

102 return self._teams.copy() 

103 

104 @property 

105 def traceable_time(self) -> TraceableTime: 

106 """Return the traceable time of the training.""" 

107 return self._traceable_time 

108 

109 @property 

110 def period(self) -> Period: 

111 """Return the period of the training.""" 

112 return self._period 

113 

114 @property 

115 def active(self) -> bool: 

116 """Return if the training is active or not.""" 

117 return self._active 

118 

119 @property 

120 def cancelled(self) -> bool: 

121 """Return if the training is cancelled or not.""" 

122 return self._cancelled 

123 

124 @property 

125 def location(self) -> str: 

126 """Return the location of the training.""" 

127 return self._location 

128 

129 @property 

130 def remark(self) -> str | None: 

131 """Return the remark.""" 

132 return self._remark