Coverage for src/tests/modules/training/test_get_training_schedules.py: 95%
19 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 use case "Get Training Schemas"."""
3import pytest
5from kwai_bc_training.get_training_schedules import (
6 GetTrainingSchedules,
7 GetTrainingSchedulesCommand,
8)
9from kwai_bc_training.trainings.training_schedule import (
10 TrainingScheduleEntity,
11)
12from kwai_bc_training.trainings.training_schedule_db_repository import (
13 TrainingScheduleDbRepository,
14)
15from kwai_bc_training.trainings.training_schedule_repository import (
16 TrainingScheduleRepository,
17)
18from kwai_core.db.database import Database
19from kwai_core.domain.presenter import CountIterableAsyncPresenter
22@pytest.fixture(scope="module")
23def training_schedule_repo(database: Database) -> TrainingScheduleRepository:
24 """A fixture for a training schema repository."""
25 return TrainingScheduleDbRepository(database)
28@pytest.fixture
29async def saved_training_schedule(
30 training_schedule_repo: TrainingScheduleRepository,
31 training_schema: TrainingScheduleEntity,
32) -> TrainingScheduleEntity:
33 """A fixture for a training schema in the database."""
34 return await training_schedule_repo.create(training_schema)
37async def test_get_training_schemas(
38 training_schedule_repo: TrainingScheduleRepository,
39 make_training_schedule_in_db,
40):
41 """Test a successful execution of the use case."""
42 await make_training_schedule_in_db()
43 command = GetTrainingSchedulesCommand()
44 presenter = CountIterableAsyncPresenter[TrainingScheduleEntity]()
45 await GetTrainingSchedules(training_schedule_repo, presenter).execute(command)
46 assert presenter.count > 0, "There should be at least a training schedule"