Coverage for src/tests/modules/club/test_update_coach.py: 100%

14 statements  

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

1"""Module for testing the use case 'Update Coach'.""" 

2 

3import pytest 

4 

5from kwai_bc_club.domain.club_coach import ClubCoachEntity 

6from kwai_bc_club.repositories.coach_db_repository import CoachDbRepository 

7from kwai_bc_club.update_coach import UpdateCoach, UpdateCoachCommand 

8from kwai_core.db.database import Database 

9from kwai_core.domain.presenter import EntityPresenter 

10 

11 

12pytestmark = pytest.mark.db 

13 

14 

15async def test_update_coach(make_coach_in_db, database: Database): 

16 """Test the update coach use case.""" 

17 coach = await make_coach_in_db() 

18 command = UpdateCoachCommand( 

19 id=coach.id.value, 

20 remark="Test Update", 

21 description=coach.description, 

22 diploma=coach.diploma, 

23 active=coach.active, 

24 ) 

25 presenter = EntityPresenter[ClubCoachEntity]() 

26 await UpdateCoach(CoachDbRepository(database), presenter).execute(command) 

27 assert presenter.entity is not None, "There should be a training" 

28 assert presenter.entity.remark == "Test Update", "The remark should be updated"