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
« 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."""
3from dataclasses import dataclass
5from kwai.core.domain.value_objects.identifier import IntIdentifier
6from kwai.modules.portal.applications.application_repository import (
7 ApplicationRepository,
8)
11@dataclass(kw_only=True, frozen=True, slots=True)
12class GetApplicationCommand:
13 """Input for the use case [GetApplication][kwai.modules.portal.get_application.GetApplication].
15 Attributes:
16 id: The id of the application
17 """
19 id: int
22class GetApplication:
23 """Implements the use case 'get application'."""
25 def __init__(self, application_repo: ApplicationRepository):
26 """Initialize the use case.
28 Args:
29 application_repo: A repository for getting applications.
30 """
31 self._application_repo = application_repo
33 async def execute(self, command: GetApplicationCommand):
34 """Execute the use case.
36 Args:
37 command: The input for this use case.
38 """
39 return await self._application_repo.get_by_id(IntIdentifier(command.id))