Improve test coverage (87% → 95%)#17
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds 44 new tests across 6 test files to close coverage gaps identified in the existing test suite. No production code changes — only new tests, version bump, and changelog update.
Changes
GetImageUseCase.execute()andget_file()— all branches including missing path for original/thumbnail_record_upload()and_record_duration()metrics paths, including error swallowing_check_databasefailure,_check_storagemissing directory, degraded health endpointasync_shutdown_executor(no-op, normal, timeout/force-cancel), executor singleton,shutdown_executorMetricsMiddleware(skip /health and /metrics, record normal/4xx/5xx),setup_tracing,setup_metrics,instrument_loggingSettings.database_url(including special char encoding),build_engine/build_session_factory,create_app± CORS,_is_otel_enabled/_is_cors_enabledhelpers,JSONFormatterwith exc_info,InMemoryImageCache._evict_oldeston empty storeCoverage improvement
Key modules improved
observability/middleware.py: 0% → 100%observability/setup.py: 0% → 80%Remaining uncovered (by design)
The remaining 52 lines are in OTel-gated branches in main.py (lifespan with OTel enabled, metrics endpoint) and DI factory wiring in dependencies.py — these require a live database or full OTel stack and are appropriately skipped in unit tests.
Version
2.2.2→2.2.3(PATCH — tests only)Checklist
ruff check— all passedruff format --check— all formattedmypy— no issues in 6 source filespytest— 260 passed