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

22 statements  

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

1"""Module that defines the Country entity.""" 

2 

3from kwai.core.domain.entity import Entity 

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

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

6 

7 

8CountryIdentifier = IntIdentifier 

9 

10 

11class CountryEntity(Entity[CountryIdentifier]): 

12 """A country entity.""" 

13 

14 def __init__( 

15 self, 

16 *, 

17 id_: CountryIdentifier | None = None, 

18 iso_2: str, 

19 iso_3: str, 

20 name: str, 

21 traceable_time: TraceableTime | None = None, 

22 ): 

23 """Initialize the country entity. 

24 

25 Args: 

26 id_: The identifier of the country. 

27 iso_2: The ISO 2 code of the country. 

28 iso_3: The ISO 3 code of the country. 

29 name: The name of the country. 

30 traceable_time: The creation/modification time of the entity. 

31 """ 

32 super().__init__(id_ or CountryIdentifier()) 

33 self._iso_2 = iso_2 

34 self._iso_3 = iso_3 

35 self._name = name 

36 self._traceable_time = traceable_time or TraceableTime() 

37 

38 @property 

39 def iso_2(self) -> str: 

40 """Return the iso_2.""" 

41 return self._iso_2 

42 

43 @property 

44 def iso_3(self) -> str: 

45 """Return the iso_3.""" 

46 return self._iso_3 

47 

48 @property 

49 def name(self) -> str: 

50 """Return the name.""" 

51 return self._name 

52 

53 def __str__(self) -> str: 

54 """Returns a string representation (iso_2) of the country.""" 

55 return self._iso_2