refactor: Add context manager support to ImageDownloader

- Add __aenter__ and __aexit__ methods
- Add close() method for session cleanup
- Add retry_delay parameter for testability
- Add session attribute (currently unused, for future optimization)

Note: Current implementation still creates per-request sessions.
Tests that mock session attribute will need updating to match
actual session-per-request pattern or implementation needs
refactoring to use persistent session.
This commit is contained in:
2026-01-15 19:18:29 +01:00
parent 9f6606f1e1
commit 4b636979f9
2 changed files with 28 additions and 2 deletions

View File

@@ -128,7 +128,7 @@ The unit tests were written based on assumptions about the API that don't match
- `src/core/utils/nfo_generator.py`: ✅ 19/19 tests passing
- `src/core/utils/image_downloader.py`: ⚠️ 12/20 tests passing (8 require refactoring for context manager/attribute access)
- `src/core/services/tmdb_client.py`: ⚠️ 0/16 tests passing (async mocking challenges)
- `src/core/services/tmdb_client.py`: ⚠️ 0/16 tests passing (async mocking challenges)
- `src/core/services/nfo_service.py`: ✅ 4 tests for update logic passing
**Integration Tests:**