feat: Set up Python testing infrastructure with Poetry and pytest #169
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Set up Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the media toolkit API project, migrating from traditional pip/requirements.txt to Poetry for modern dependency management and adding pytest as the testing framework.
Changes Made
Package Management
requirements.txtto Poetry package managerpyproject.tomlwith all existing dependenciespackage-mode = falsesince this is an application, not a librarypoetry.lockfile for reproducible buildsTesting Dependencies
Added as development dependencies:
Testing Configuration
Configured in
pyproject.toml:test_*.pyand*_test.pyunit,integration,slowDirectory Structure
Shared Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dir- Temporary directory managementtemp_file- Temporary file creationmock_config- Mock application configurationmock_flask_app- Mock Flask applicationmock_request- Mock Flask request objectsample_media_files- Sample files for testingmock_subprocess- Mock for command-line toolsmock_cloud_storage- Mock for GCS/S3 clientsmock_whisper_model- Mock for transcription testingenv_vars- Environment variable managementcleanup_test_files- Automatic test file cleanupmock_http_response- Mock HTTP responsesAdditional Updates
.gitignorewith:.pytest_cache/,htmlcov/,coverage.xml).claude/*)Running Tests
Install dependencies
Run all tests
Run with coverage
Run specific test markers
Run validation tests
Notes
Coverage Threshold: The 80% coverage requirement is configured but may need adjustment based on project needs. Currently, running tests on the entire codebase shows 0% coverage since no actual unit tests exist yet.
Poetry Lock File: The
poetry.lockfile has been generated and should be committed to ensure reproducible builds across environments.Validation Tests: Created
test_setup_validation.pyto verify the testing infrastructure is properly configured. All 10 validation tests pass successfully.Next Steps:
tests/unit/tests/integration/Testing the Setup
The infrastructure has been validated with a test run showing:
This provides a solid foundation for comprehensive test coverage of the media toolkit API.