🔒 Validation: torrent qBittorrent retire sans ses donnees - le MKV lie du dossier du film est hors de portee de qBittorrent

This commit is contained in:
Orionis312050 committed 2026-10-13 22:23:45 +00:00
1 parent e07a887c34
commit 231a1f2599
3 files changed
+63 -3

No files matched your search

+55
View File
@@ -623,3 +623,58 @@ def test_scan_refreshes_paths_of_processed_movies() -> None:
assert row.radarr_linked is True
assert row.path == "/movies/Film Traité (2020)/Film Traité (2020).mkv"
assert row.size == 42_000_000_000
@respx.mock
def test_validation_removes_torrent_without_files() -> None:
"""La validation retire le torrent qBittorrent SANS ses donnees: l'ISO
est deja supprimee par nom et le MKV converti vit dans le meme dossier —
qBittorrent ne doit pouvoir y toucher en aucun cas."""
reset_state()
create_film_folder()
mock_radarr(str(settings.radarr_films_dir / FILM_FOLDER))
# qBittorrent configure (cle API): le torrent de l'ISO existe.
torrents_route = respx.get("http://qbit:8080/api/v2/torrents/info").mock(
return_value=Response(
200,
json=[
{
"hash": "abc123",
"name": ISO_NAME,
"content_path": f"/qbittorrentdownloads/{ISO_NAME}",
}
],
)
)
delete_route = respx.post("http://qbit:8080/api/v2/torrents/delete").mock(
return_value=Response(200)
)
respx.post("http://radarr:7878/api/v3/command").mock(
return_value=Response(201, json={"id": 1})
)
with TestClient(app) as client:
configure_radarr(client)
client.put(
"/api/settings/qbittorrent",
json={"url": "http://qbit:8080", "port": 8080, "api_key": "qbt_key"},
)
client.post("/api/scans")
movie_id = client.get("/api/movies").json()[0]["id"]
client.post(f"/api/movies/{movie_id}/convert")
wait_for_status(client, "validating")
validate = client.post(f"/api/movies/{movie_id}/validate")
assert validate.status_code == 200
assert validate.json()["status"] == "completed"
# Le torrent correspondant a l'ISO a ete retire...
assert torrents_route.called
assert delete_route.called
body = delete_route.calls.last.request.content.decode()
assert "hashes=abc123" in body
# ...sans ses donnees: le MKV du dossier du film est hors de portee.
assert "deleteFiles=false" in body
assert "deleteFiles=true" not in body
# Le MKV lie survit a la validation.
assert (film_dir() / MKV_NAME).is_file()