fix: release cooldown on local media failures
This commit is contained in:
+20
-1
@@ -2,7 +2,7 @@ import json
|
||||
from pathlib import Path
|
||||
|
||||
from rf4_research import media_cli
|
||||
from rf4_research.media_cli import _download_batch, media_queue_plan
|
||||
from rf4_research.media_cli import _download_batch, _download_one, media_queue_plan
|
||||
|
||||
|
||||
def test_queue_plan_prioritizes_entity_gaps_and_respects_domain_cooldown(tmp_path: Path) -> None:
|
||||
@@ -101,3 +101,22 @@ def test_batch_downloads_quality_upgrade_without_unpublishing_fallback(tmp_path:
|
||||
assert report["stored_total"] == 1
|
||||
assets = json.loads((root / "manifest.json").read_text(encoding="utf-8"))["assets"]
|
||||
assert assets[0]["status"] == "upgrade_stored"
|
||||
|
||||
|
||||
def test_local_failure_releases_media_reservation(tmp_path: Path, monkeypatch) -> None:
|
||||
root = tmp_path / "media"
|
||||
root.mkdir()
|
||||
(root / "manifest.json").write_text(json.dumps({"version": 1, "assets": [
|
||||
{"status": "queued", "asset_url": "https://rf4map.ru/fish.png"},
|
||||
]}), encoding="utf-8")
|
||||
state = tmp_path / "state.json"
|
||||
monkeypatch.setattr(media_cli, "_attempt_asset", lambda *_: ("queued", OSError("DNS unavailable")))
|
||||
|
||||
try:
|
||||
_download_one(root, state, "https://rf4map.ru/fish.png")
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
raise AssertionError("local media failure must be raised")
|
||||
|
||||
assert not state.exists() or "rf4map.ru" not in json.loads(state.read_text(encoding="utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user