Coverage for src/kwai/modules/training/get_teams.py: 100%

9 statements  

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

1"""Module that defines a use case for getting teams.""" 

2 

3from kwai.core.domain.use_case import UseCaseBrowseResult 

4from kwai.modules.training.teams.team_repository import TeamRepository 

5 

6 

7class GetTeams: 

8 """Use case for getting teams.""" 

9 

10 def __init__(self, team_repo: TeamRepository): 

11 """Initialize the use case. 

12 

13 Args: 

14 team_repo: The repository for getting the teams. 

15 """ 

16 self._team_repo = team_repo 

17 

18 async def execute(self) -> UseCaseBrowseResult: 

19 """Execute the use case.""" 

20 team_query = self._team_repo.create_query() 

21 count = await team_query.count() 

22 

23 return UseCaseBrowseResult( 

24 count=count, 

25 iterator=self._team_repo.get_all(), 

26 )