Coverage for src/kwai/modules/club/domain/person.py: 100%

39 statements  

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

1"""Module that defines an entity for a person.""" 

2 

3from kwai.core.domain.entity import Entity 

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

5from kwai.core.domain.value_objects.name import Name 

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

7from kwai.modules.club.domain.contact import ContactEntity 

8from kwai.modules.club.domain.country import CountryEntity 

9from kwai.modules.club.domain.value_objects import Birthdate, Gender 

10 

11 

12PersonIdentifier = IntIdentifier 

13 

14 

15class PersonEntity(Entity[PersonIdentifier]): 

16 """A person entity.""" 

17 

18 def __init__( 

19 self, 

20 *, 

21 id_: PersonIdentifier | None = None, 

22 name: Name, 

23 gender: Gender, 

24 birthdate: Birthdate, 

25 nationality: CountryEntity, 

26 contact: ContactEntity, 

27 remark: str = "", 

28 traceable_time: TraceableTime | None = None, 

29 ): 

30 """Initialize a person. 

31 

32 Args: 

33 id_: The id of the person. 

34 name: The name of the person. 

35 gender: The gender of the person. 

36 birthdate: The birthdate of the person. 

37 nationality: The nationality of the person. 

38 contact: The related contact entity. 

39 remark: A remark about the person. 

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

41 """ 

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

43 self._name = name 

44 self._gender = gender 

45 self._birthdate = birthdate 

46 self._nationality = nationality 

47 self._contact = contact 

48 self._remark = remark 

49 self._traceable_time = traceable_time or TraceableTime() 

50 

51 @property 

52 def name(self) -> Name: 

53 """Return the name of the person.""" 

54 return self._name 

55 

56 @property 

57 def gender(self) -> Gender: 

58 """Return the gender of the person.""" 

59 return self._gender 

60 

61 @property 

62 def birthdate(self) -> Birthdate: 

63 """Return the birthdate of the person.""" 

64 return self._birthdate 

65 

66 @property 

67 def remark(self) -> str: 

68 """Return the remark.""" 

69 return self._remark 

70 

71 @property 

72 def contact(self) -> ContactEntity: 

73 """Return the contact.""" 

74 return self._contact 

75 

76 @property 

77 def nationality(self) -> CountryEntity: 

78 """Return the nationality.""" 

79 return self._nationality 

80 

81 @property 

82 def traceable_time(self) -> TraceableTime: 

83 """Return the traceable_time.""" 

84 return self._traceable_time