fix: use config.IMAGE_TIMEOUT for image URL download#151
Conversation
Agent-Logs-Url: https://github.com/CyberSecDef/NovelForge/sessions/3dce1d7f-7ddb-4344-91fb-b5d0f4da598a Co-authored-by: CyberSecDef <17597068+CyberSecDef@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes image URL download to respect the user-configured config.IMAGE_TIMEOUT (previously hardcoded to 60s), and adds regression tests to ensure the timeout value is propagated into the requests.get call.
Changes:
- Use
config.IMAGE_TIMEOUTfor the image download (requests.get) timeout incall_image_api. - Add tests verifying
requests.get(..., timeout=...)matchesconfig.IMAGE_TIMEOUTfor custom values (120, 300).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
novelforge/llm/image.py |
Applies config.IMAGE_TIMEOUT to the image URL download request. |
tests/test_image_download_timeout.py |
Adds regression tests asserting download timeout uses config.IMAGE_TIMEOUT. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import base64 | ||
| import json |
There was a problem hiding this comment.
base64 and json are imported but not used in this test module. Removing unused imports will keep the tests clean and avoid failing future linting/static checks if introduced.
| import base64 | |
| import json |
| image_mod.call_image_api("sunset scene", filename_prefix="cover") | ||
|
|
||
| actual_timeout = get_calls[0]["kwargs"].get("timeout") | ||
| assert actual_timeout == 300, ( | ||
| f"Expected timeout=config.IMAGE_TIMEOUT (300), got {actual_timeout!r}" | ||
| ) |
There was a problem hiding this comment.
test_download_timeout_reflects_updated_config accesses get_calls[0] without first asserting that requests.get was called. Adding an explicit len(get_calls) == 1 assertion (as in the previous test) will produce a clearer failure if the download path changes.
IMAGE_TIMEOUTwas applied to the image generation POST but reverted to a hardcoded 60s for the subsequent URL download, silently ignoring user configuration.Changes
novelforge/llm/image.py: Replacetimeout=60withtimeout=config.IMAGE_TIMEOUTin therequests.getdownload calltests/test_image_download_timeout.py: New tests asserting thetimeoutkwarg passed torequests.getmatchesconfig.IMAGE_TIMEOUTfor custom values (120s, 300s)