feat: '+ To library' — add the current audio area straight to the clip library

This commit is contained in:
2026-07-04 01:11:05 +02:00
parent 0e82a82cde
commit 158483ce42
2 changed files with 80 additions and 1 deletions
+32
View File
@@ -448,6 +448,38 @@ def test_extract_no_edits_passes_no_filters(win, monkeypatch, tmp_path):
assert seen["filters"] is None
def test_add_selection_to_library(win, tmp_path, monkeypatch):
import main as m
win._file_path = "/vids/Chloe.mp4"
win._cursor = 7.0
win._spn_audio_len.setValue(3.0)
win._settings.setValue("audio_extract_dir", str(tmp_path))
win._settings.setValue("audio_library_dir", "") # force derive
seen = {}
def fake_cmd(inp, start, dur, out, filters=None):
seen["out"] = out; seen["start"] = start; seen["dur"] = dur; return ["true"]
monkeypatch.setattr(m, "build_audio_clip_command", fake_cmd)
monkeypatch.setattr(m.subprocess, "run",
lambda *a, **k: type("P", (), {"returncode": 0})())
monkeypatch.setattr(m.os.path, "exists", lambda p: True)
monkeypatch.setattr(m, "probe_duration", lambda p: 3.0)
lib = win._scan_panel._library
lib._key = "audio_library_addsel_test"
win._settings.setValue(lib._key, [])
lib._list.clear()
win._on_add_selection_to_library()
# rendered the current area with the managed-folder auto-name
assert seen["start"] == 7.0 and seen["dur"] == 3.0
assert os.path.join("audio_library", "Chloe_7.00-10.00s.wav") in seen["out"]
# and it was added to the library
assert seen["out"] in lib.clips()
def test_add_selection_to_library_no_file_safe(win):
win._file_path = ""
win._on_add_selection_to_library() # must not raise
def test_waveform_strip_present_and_safe(win):
from PyQt6.QtWidgets import QPushButton
assert win._wave is not None