The project includes comprehensive test coverage across three main test files:
Unit tests for Flask endpoints:
test_convert_endpoint_with_html_file- Successful HTML conversiontest_convert_endpoint_rejects_unsupported_extension- Extension validation
Unit tests for core conversion logic:
test_convert_to_markdown_html_fixture- HTML to Markdown conversiontest_allowed_file_accepts_supported_extensions- File type validation
Integration tests with generated sample files:
test_convert_all_sample_files- Tests all 8 file format types (HTML, CSV, JSON, XML, PDF, DOCX, PPTX, XLSX)test_convert_remote_samples- Optional remote samples from Apache POI repository
Comprehensive error case and edge condition tests:
- Endpoint validation (13 tests) - Missing fields, empty files, path traversal, special characters, method validation
- Allowed file function (10 tests) - Extension validation, case sensitivity, unsupported formats
pytest # Run all tests
pytest tests/test_app.py # Run specific test file
pytest -v # Verbose output
pytest -k test_convert # Run tests matching patternpytest --cov=app --cov=utils --cov-report=term-missing
pytest --cov=app --cov=utils --cov-report=html # Generates htmlcov/index.html
coverage report --fail-under=75 # Enforce coverage threshold| Module | Target | Notes |
|---|---|---|
app.py |
90%+ | Core Flask endpoints and handlers |
utils/converter.py |
85%+ | File conversion logic |
| Overall | 75%+ | Minimum threshold enforced in CI |
The test workflow in .github/workflows/tests.yml includes:
- pytest execution with coverage collection
- Coverage reporting - Terminal output and HTML report
- Threshold checking - Warns if coverage drops below 75%
- Docker smoke test - Full end-to-end integration test
Coverage results are displayed in workflow logs and can be reviewed locally via htmlcov/index.html.
- ✅ HTML, CSV, JSON, XML conversion
- ✅ Binary formats (PDF, DOCX, PPTX, XLSX)
- ✅ Image formats (PNG, JPG, GIF)
- ✅ Audio formats (MP3, WAV with mocking)
- ✅ Remote sample files
- ✅ Missing file field in request
- ✅ Empty filenames
- ✅ Unsupported file extensions
- ✅ Malformed HTML/JSON
- ✅ Path traversal attempts (sanitized)
- ✅ Special characters in filenames
- ✅ Whitespace-only filenames
- ✅ Wrong content for file extension
- ✅ Case-insensitive extension checking
- ✅ Empty files
- ✅ Very long filenames
- ✅ Multiple dots in filename
- ✅ Hidden files (dot files)
- ✅ Uppercase extensions
- ✅ HTTP method validation (GET on POST-only endpoint)
- Large file uploads (>100MB)
- Concurrent file conversions
- Custom error logging verification
- Performance benchmarks
- Memory usage during conversion
- Disk space limits
- Network timeouts in remote sample download
The .coveragerc file excludes:
- Test files themselves
- Abstract method stubs
- Main entry points
- Type checking blocks
Tests should be updated when:
- New file formats are added
- New endpoints are created
- Error cases are discovered
- Security issues are patched
Run tests frequently during development:
pytest -v --tb=short # During development
pytest --cov --cov-report=html # Before commitsAfter modifying code:
# Install dependencies
poetry install --with dev
# Run all tests
pytest -v
# Check coverage
pytest --cov=app --cov=utils --cov-report=term-missing
# Review HTML report
open htmlcov/index.html