Tests for Speech Coach Project
This directory contains tests for the Speech Coach project. The test structure reflects the source code structure.
Structure
tests/
├── conftest.py - common fixtures for tests
└── src/
└── shared/ - tests for shared components
├── services/ - tests for services
├── schemas/ - tests for data schemas
└── messaging/ - tests for messaging components
Running Tests
To run all tests:
python -m pytest
To run tests with code coverage:
python -m pytest --cov=src
To run specific tests:
python -m pytest tests/src/shared/services/test_audio_service.py
Fixtures
Common fixtures for tests are defined in the conftest.py file:
event_loop- fixture for enabling asynchronous testsmock_config- mock for configurationmock_broker- mock for message brokertemp_file- fixture for creating a temporary filetemp_ogg_file- fixture for creating a temporary audio filemock_s3_client- mock for S3 client (MinIO)
Adding New Tests
When adding new tests, follow these principles:
- Create tests in the appropriate directories reflecting the project structure
- Use the
test_prefix for test files and functions - Use fixtures from
conftest.pyfor common operations - For asynchronous tests, use the
@pytest.mark.asynciodecorator
Code Coverage
Aim for test code coverage of at least 80%. Focus mainly on business logic and error handling.