Coverage for bc/kwai-bc-training/src/kwai_bc_training/get_teams.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.11.0, 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 

4 

5from kwai_bc_training.teams.team_repository import TeamRepository 

6 

7 

8class GetTeams: 

9 """Use case for getting teams.""" 

10 

11 def __init__(self, team_repo: TeamRepository): 

12 """Initialize the use case. 

13 

14 Args: 

15 team_repo: The repository for getting the teams. 

16 """ 

17 self._team_repo = team_repo 

18 

19 async def execute(self) -> UseCaseBrowseResult: 

20 """Execute the use case.""" 

21 team_query = self._team_repo.create_query() 

22 count = await team_query.count() 

23 

24 return UseCaseBrowseResult( 

25 count=count, 

26 iterator=self._team_repo.get_all(), 

27 )