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

1"""Module that implements the use case 'Get Team'.""" 

2 

3from dataclasses import dataclass 

4 

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 

8 

9 

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

11class GetTeamCommand: 

12 """Input for the use case 'Get Team'.""" 

13 

14 id: int 

15 

16 

17class GetTeam: 

18 """Implement the use case 'Get Teams'.""" 

19 

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 

28 

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))