Coverage for src/kwai/modules/teams/get_team.py: 100%
15 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 implements the use case 'Get Team'."""
3from dataclasses import dataclass
5from kwai.core.domain.presenter import Presenter
6from kwai.modules.teams.domain.team import TeamEntity, TeamIdentifier
7from kwai.modules.teams.repositories.team_repository import TeamRepository
10@dataclass(kw_only=True, frozen=True, slots=True)
11class GetTeamCommand:
12 """Input for the use case 'Get Team'."""
14 id: int
17class GetTeam:
18 """Implement the use case 'Get Teams'."""
20 def __init__(
21 self,
22 team_repo: TeamRepository,
23 presenter: Presenter[TeamEntity],
24 ):
25 """Initialize the use case."""
26 self._team_repo = team_repo
27 self._presenter = presenter
29 async def execute(self, command: GetTeamCommand) -> None:
30 """Execute the use case."""
31 query = self._team_repo.create_query()
32 query.filter_by_id(TeamIdentifier(command.id))
33 self._presenter.present(await self._team_repo.get(query))