mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-11-27 08:41:13 +00:00
Newznab and Jackett fell back to the download URL sent with the queue request when the release was no longer in the cache. Prowlarr already returns no URL in that case, so this makes the other two match it: the retry URL comes from the cache and nothing else. A request for a release that has expired from the cache now fails with "Release not found in cache" instead of being queued with whatever URL came along. The new tests cover both handlers on a cache miss and with no source_id, and they fail on main. Full suite, ruff and basedpyright pass.
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""The retry URL comes from server data, never from the queue request."""
|
|
|
|
import pytest
|
|
|
|
from shelfmark.download import orchestrator
|
|
|
|
|
|
@pytest.mark.parametrize("source", ["newznab", "jackett"])
|
|
def test_cache_miss_drops_client_supplied_download_url(source):
|
|
fields = orchestrator._build_retry_resolution_fields(
|
|
{
|
|
"source": source,
|
|
"source_id": "not-in-the-cache",
|
|
"download_url": "http://169.254.169.254/latest/meta-data/",
|
|
"protocol": "torrent",
|
|
"title": "Some Book",
|
|
}
|
|
)
|
|
|
|
assert fields["retry_download_url"] is None
|
|
assert fields["retry_download_protocol"] is None
|
|
|
|
|
|
@pytest.mark.parametrize("source", ["newznab", "jackett"])
|
|
def test_missing_source_id_drops_client_supplied_download_url(source):
|
|
fields = orchestrator._build_retry_resolution_fields(
|
|
{"source": source, "download_url": "http://10.0.0.1/x", "protocol": "usenet"}
|
|
)
|
|
|
|
assert fields["retry_download_url"] is None
|
|
assert fields["retry_download_protocol"] is None
|