✨ Selection du titre le plus long (robot TINFO) + code de sortie/signal dans l'erreur MakeMKV
This commit is contained in:
1 parent
39319b7caa
commit
078905e944
2 files changed
+100
-4
No files matched your search
@@ -195,3 +195,57 @@ def test_extract_fails_with_activation_error_when_makemkv_unactivated(
|
||||
assert "MAKEMKV_KEY" in str(error)
|
||||
else:
|
||||
raise AssertionError("RuntimeError attendue")
|
||||
|
||||
|
||||
def test_extract_reports_signal_kill(monkeypatch, tmp_path) -> None:
|
||||
"""Un processus tue par signal (ex: OOM) est identifie dans l'erreur."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
monkeypatch.setattr(settings, "simulate_conversion", False)
|
||||
monkeypatch.setattr("app.converter.shutil.which", lambda _: "/usr/bin/makemkvcon")
|
||||
monkeypatch.setattr(
|
||||
"app.converter.subprocess.run",
|
||||
lambda *args, **kwargs: SimpleNamespace(returncode=-9, stdout="", stderr=""),
|
||||
)
|
||||
movie = IsoMovie(
|
||||
radarr_movie_id=1, radarr_movie_file_id=2, title="ISO Movie", path="/x.iso"
|
||||
)
|
||||
try:
|
||||
extract_mkv(movie, tmp_path / "out" / "movie.mkv")
|
||||
except RuntimeError as error:
|
||||
assert "SIGKILL" in str(error)
|
||||
else:
|
||||
raise AssertionError("RuntimeError attendue")
|
||||
|
||||
|
||||
def test_extract_picks_longest_title(monkeypatch, tmp_path) -> None:
|
||||
"""Le titre extrait est le plus long, pas le numero 0."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
robot_info = "\n".join(
|
||||
[
|
||||
'MSG:1005,0,1,"MakeMKV started"',
|
||||
'TINFO:0,9,0,"0:02:30"',
|
||||
'TINFO:1,9,0,"1:57:00"',
|
||||
'TINFO:2,9,0,"0:24:13"',
|
||||
]
|
||||
)
|
||||
|
||||
def fake_run(args, **kwargs):
|
||||
if "--robot" in args:
|
||||
return SimpleNamespace(returncode=0, stdout=robot_info, stderr="")
|
||||
# Commande mkv: on verifie le titre choisi et on simule la sortie.
|
||||
assert args[3] == "1", f"titre attendu: 1, commande: {args}"
|
||||
out = tmp_path / "out"
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
(out / "movie.mkv").write_text("mkv")
|
||||
return SimpleNamespace(returncode=0, stdout="", stderr="")
|
||||
|
||||
monkeypatch.setattr(settings, "simulate_conversion", False)
|
||||
monkeypatch.setattr("app.converter.shutil.which", lambda _: "/usr/bin/makemkvcon")
|
||||
monkeypatch.setattr("app.converter.subprocess.run", fake_run)
|
||||
movie = IsoMovie(
|
||||
radarr_movie_id=1, radarr_movie_file_id=2, title="ISO Movie", path="/x.iso"
|
||||
)
|
||||
extract_mkv(movie, tmp_path / "out" / "movie.mkv")
|
||||
assert (tmp_path / "out" / "movie.mkv").exists()
|
||||
Reference in new issue
Block a user