Coverage for src/kwai/modules/portal/get_application.py: 100%

11 statements  

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

1"""Module that defines the use case: get application for a portal.""" 

2 

3from dataclasses import dataclass 

4 

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

6from kwai.modules.portal.applications.application_repository import ( 

7 ApplicationRepository, 

8) 

9 

10 

11@dataclass(kw_only=True, frozen=True, slots=True) 

12class GetApplicationCommand: 

13 """Input for the use case [GetApplication][kwai.modules.portal.get_application.GetApplication]. 

14 

15 Attributes: 

16 id: The id of the application 

17 """ 

18 

19 id: int 

20 

21 

22class GetApplication: 

23 """Implements the use case 'get application'.""" 

24 

25 def __init__(self, application_repo: ApplicationRepository): 

26 """Initialize the use case. 

27 

28 Args: 

29 application_repo: A repository for getting applications. 

30 """ 

31 self._application_repo = application_repo 

32 

33 async def execute(self, command: GetApplicationCommand): 

34 """Execute the use case. 

35 

36 Args: 

37 command: The input for this use case. 

38 """ 

39 return await self._application_repo.get_by_id(IntIdentifier(command.id))