Increase test coverage for undertested modules#12
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 48 new tests targeting four modules that previously had low coverage:
PostgresImageRepository(23%),ListImagesUseCase(64%),PillowImageProcessorsync workers (67%), and main.py lifespan (69%). All four modules now reach 100% coverage. Overall test count goes from 168 to 216.Changes
Added
test_postgres_image_repository.py (28 tests)
SQLite-backed integration tests for
PostgresImageRepository. Exercises all 8 repository methods (save,get_by_id,list_images,delete,get_expired,delete_expired_batch,count) with real SQL queries and ORM mapping round-trips, usingaiosqlite(already a dev dependency). PostgreSQL-specific column types (UUID,ARRAY) are swapped to SQLite equivalents at fixture time.test_list_images.py (5 tests)
Unit tests for
ListImagesUseCasecovering empty results, response mapping (metadata/thumbnail), pagination parameter forwarding, status filter forwarding, and total-vs-page-size distinction.test_pillow_processor.py (12 new tests)
Direct in-process tests for
_generate_thumbnail_sync(aspect ratio, RGBA, small images, JPEG format, corrupt data) and_extract_metadata_sync(RGB/RGBA/grayscale, corrupt data), plusshutdown_executorlifecycle tests. These functions previously ran only inProcessPoolExecutorchild processes invisible to the coverage collector.test_lifespan.py (3 tests)
Integration tests for the FastAPI
lifespanasync context manager: startup table creation, shutdown cleanup (engine.dispose,shutdown_executor), and log message verification.Fixed
HTTP_422_UNPROCESSABLE_ENTITYwithHTTP_422_UNPROCESSABLE_CONTENTin the upload validation error response.Coverage impact
postgres_image_repository.pyVersion
PATCH bump:
2.0.1→2.0.2Checklist
ruff check— no issuesmypy src/— no issuespytest— 216 passed