Testing Strategy
The YouTube Transcript Summarizer employs a comprehensive testing strategy to ensure reliability and correctness.
Test Types
- Unit Tests: Test individual components in isolation
- Integration Tests: Test interactions between components
- API Tests: Test API endpoints and responses
Key Test Files
- tests/test_main.py: Tests for FastAPI routes
- tests/test_youtube_api_service.py: Tests for YouTube API service
- tests/test_openai_api_service.py: Tests for OpenAI API service
- tests/test_json_user_model.py: Tests for JSON-based user model
- tests/test_db_user_model.py: Tests for database user model
- pytest: Test runner and framework
- TestClient: FastAPI’s testing client for API tests
- unittest.mock: For mocking external dependencies
Running Tests
To run all tests:
pytest
To run tests with coverage:
pytest –cov=.
Continuous Integration
Tests are automatically run on GitHub Actions for every push and pull request to ensure code quality and prevent regressions.
Mocking
External services (YouTube API, OpenAI API) are mocked in tests to avoid actual API calls and ensure consistent test behavior.
For more details on specific tests, refer to the individual test files in the tests/ directory.