Coverage for src/kwai/modules/teams/create_team.py: 100%
16 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 'Create Team'."""
3from dataclasses import dataclass
5from kwai.core.domain.presenter import Presenter
6from kwai.modules.teams.domain.team import TeamEntity
7from kwai.modules.teams.repositories.team_repository import TeamRepository
10@dataclass(kw_only=True, frozen=True, slots=True)
11class CreateTeamCommand:
12 """Input for the use case 'Create Team'."""
14 name: str
15 active: bool
16 remark: str
19class CreateTeam:
20 """Use case 'Create Team'."""
22 def __init__(self, team_repo: TeamRepository, presenter: Presenter[TeamEntity]):
23 """Initialize the use case.
25 Args:
26 team_repo: A repository that creates the team.
27 presenter: A presenter for a team entity.
28 """
29 self._team_repo = team_repo
30 self._presenter = presenter
32 async def execute(self, command: CreateTeamCommand) -> None:
33 """Executes the use case."""
34 team = TeamEntity(
35 name=command.name, active=command.active, remark=command.remark
36 )
37 self._presenter.present(await self._team_repo.create(team))