Migrate from Poetry and pyenv to uv

This commit is contained in:
2026-10-12 15:48:26 +02:00
parent c399a6aed3
commit c69f5f9166
93 changed files with 13068 additions and 2401 deletions
+16 -11
View File
@@ -3,6 +3,7 @@
The FFmpeg subprocess call is monkeypatched so the tests don't need ffmpeg
installed and don't touch real video data.
"""
import subprocess
from pathlib import Path
from types import SimpleNamespace
@@ -23,6 +24,7 @@ def video_file(tmp_path) -> Path:
def _fake_run(returncode=0, stdout="", stderr=""):
def run(cmd, **kwargs):
return SimpleNamespace(returncode=returncode, stdout=stdout, stderr=stderr)
return run
@@ -36,8 +38,10 @@ def test_deep_clean_file_is_ok(monkeypatch, video_file):
def test_deep_reports_decode_errors(monkeypatch, video_file):
monkeypatch.setattr(integrity.shutil, "which", lambda _: "/usr/bin/ffmpeg")
monkeypatch.setattr(
integrity.subprocess, "run",
_fake_run(1, "", "[matroska @ 0x..] Read error\nmore noise"))
integrity.subprocess,
"run",
_fake_run(1, "", "[matroska @ 0x..] Read error\nmore noise"),
)
result = check_video_integrity(video_file, deep=True)
assert not result.ok and result.checked
assert result.error == "[matroska @ 0x..] Read error" # first line only
@@ -46,8 +50,7 @@ def test_deep_reports_decode_errors(monkeypatch, video_file):
def test_deep_stderr_without_nonzero_rc_still_fails(monkeypatch, video_file):
"""ffmpeg can print decode errors while returning rc 0 — must still fail."""
monkeypatch.setattr(integrity.shutil, "which", lambda _: "/usr/bin/ffmpeg")
monkeypatch.setattr(
integrity.subprocess, "run", _fake_run(0, "", "corrupt packet"))
monkeypatch.setattr(integrity.subprocess, "run", _fake_run(0, "", "corrupt packet"))
result = check_video_integrity(video_file, deep=True)
assert not result.ok
@@ -99,9 +102,9 @@ def test_ffmpeg_available_reflects_which(monkeypatch):
def test_scan_collects_problems_and_progress(monkeypatch, tmp_path):
"""FileManager.scan_video_integrity aggregates per-file results."""
from src.core.tag_manager import TagManager
from src.core.file_manager import FileManager
from src.core.file import File
from src.core.file_manager import FileManager
from src.core.tag_manager import TagManager
good = tmp_path / "good.mkv"
bad = tmp_path / "bad.mkv"
@@ -121,7 +124,8 @@ def test_scan_collects_problems_and_progress(monkeypatch, tmp_path):
seen: list[int] = []
result = fm.scan_video_integrity(
files, deep=True, on_progress=lambda d, t, f: seen.append(d))
files, deep=True, on_progress=lambda d, t, f: seen.append(d)
)
assert result["ok"] and result["checked"] == 2
assert [r.path.name for r in result["problems"]] == ["bad.mkv"]
@@ -129,9 +133,9 @@ def test_scan_collects_problems_and_progress(monkeypatch, tmp_path):
def test_scan_stops_on_cancel(monkeypatch, tmp_path):
from src.core.tag_manager import TagManager
from src.core.file_manager import FileManager
from src.core.file import File
from src.core.file_manager import FileManager
from src.core.tag_manager import TagManager
files = []
for i in range(3):
@@ -142,7 +146,8 @@ def test_scan_stops_on_cancel(monkeypatch, tmp_path):
monkeypatch.setattr("src.core.file_manager.ffmpeg_available", lambda deep: True)
monkeypatch.setattr(
"src.core.file_manager.check_video_integrity",
lambda path, deep=True: IntegrityResult(Path(path), ok=True))
lambda path, deep=True: IntegrityResult(Path(path), ok=True),
)
fm = FileManager(TagManager())
result = fm.scan_video_integrity(files, should_cancel=lambda: True)
@@ -150,8 +155,8 @@ def test_scan_stops_on_cancel(monkeypatch, tmp_path):
def test_scan_reports_missing_ffmpeg(monkeypatch, tmp_path):
from src.core.tag_manager import TagManager
from src.core.file_manager import FileManager
from src.core.tag_manager import TagManager
monkeypatch.setattr("src.core.file_manager.ffmpeg_available", lambda deep: False)
fm = FileManager(TagManager())