Coverage for src/tests/modules/training/coaches/test_coaches_db_repository.py: 77%
26 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module for testing the coach database repository."""
3import pytest
5from kwai_bc_training.coaches.coach_db_repository import CoachDbRepository
6from kwai_core.db.database import Database
7from kwai_core.db.exceptions import QueryException
10async def test_get_by_id(database: Database, make_coach_in_db):
11 """Test get_by_id method."""
12 coach = await make_coach_in_db()
13 repo = CoachDbRepository(database)
15 try:
16 await repo.get_by_id(coach.id)
17 except QueryException as qe:
18 pytest.fail(str(qe))
21async def test_get_by_ids(database: Database, make_coach_in_db):
22 """Test get_by_ids method."""
23 repo = CoachDbRepository(database)
24 coach_1 = await make_coach_in_db()
25 coach_2 = await make_coach_in_db()
27 try:
28 {coach.id: coach async for coach in repo.get_by_ids(coach_1.id, coach_2.id)}
29 except QueryException as qe:
30 pytest.fail(str(qe))
33async def test_get_all(database: Database, make_coach_in_db):
34 """Test get_all method."""
35 await make_coach_in_db()
36 repo = CoachDbRepository(database)
38 try:
39 repo.get_all()
40 except QueryException as qe:
41 pytest.fail(str(qe))