aboutsummaryrefslogtreecommitdiff
path: root/lib/project/tests/test_cli.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-09-11 18:06:53 -0400
committerhistoria <historiavg@proton.me>2026-09-11 18:06:53 -0400
commit3eccf822e14f5f4dd1f6b96e785c0217db647c3e (patch)
tree8c3204d3568e713ae98a5cfa59b18f37a72a1722 /lib/project/tests/test_cli.py
parent077c82d9614328ff267632298da6c88009313337 (diff)
downloadproducer-3eccf822e14f5f4dd1f6b96e785c0217db647c3e.tar.gz
Remove analyze and channel selection; move reports to logs/
Diffstat (limited to 'lib/project/tests/test_cli.py')
-rw-r--r--lib/project/tests/test_cli.py37
1 files changed, 14 insertions, 23 deletions
diff --git a/lib/project/tests/test_cli.py b/lib/project/tests/test_cli.py
index 300b3a8..e02aad1 100644
--- a/lib/project/tests/test_cli.py
+++ b/lib/project/tests/test_cli.py
@@ -45,12 +45,12 @@ def test_preview_real_audio_preserves_original_and_reports_provenance(
assert source.read_bytes() == original
assert len(modes) == 2
assert {path.name for path in output_dir.iterdir()} == {
- f"input.{profile}.preview{suffix}"
- for profile in ("natural", "radio") for suffix in (".wav", ".report.json")
- }
+ f"input.{profile}.preview.wav"
+ for profile in ("natural", "radio")
+ } | {"logs"}
for profile, mode in zip(("natural", "radio"), modes):
target = output_dir / f"input.{profile}.preview.wav"
- report = json.loads(target.with_suffix(".report.json").read_text())
+ report = json.loads(pipeline.report_for(target).read_text())
info = sf.info(target)
assert info.duration == pytest.approx(5, abs=0.02)
assert info.channels == 1
@@ -88,19 +88,6 @@ def test_config_stdout_json_and_set_precedence(tmp_path, invoke, capsys):
assert settings["denoiser"] == "none"
-def test_analyze_stdout_is_json(wav, ffmpeg, invoke, capsys):
- source = wav()
- original = source.read_bytes()
- invoke("analyze", source, "--no-denoise")
- stats = json.loads(capsys.readouterr().out)
- assert stats["duration_seconds"] == pytest.approx(3)
- assert stats["channels"] == 1
- assert stats["frames"] == 144000
- assert np.isfinite(stats["loudness"]["input_i"])
- assert source.read_bytes() == original
- assert list(source.parent.iterdir()) == [source]
-
-
@pytest.mark.parametrize("start", ["nan", "inf", "-inf"])
def test_preview_rejects_nonfinite_start_before_tool_setup(
tmp_path, invoke, capsys, monkeypatch, start
@@ -148,7 +135,7 @@ def test_existing_output_is_not_overwritten(wav, tmp_path, invoke, capsys, monke
assert "Output exists" in capsys.readouterr().err
assert target.read_bytes() == b"previous master"
assert source.read_bytes() == original
- assert not target.with_suffix(".report.json").exists()
+ assert not pipeline.report_for(target).exists()
def test_overwrite_cannot_replace_input(wav, invoke, capsys, monkeypatch):
@@ -183,7 +170,7 @@ def test_default_outputs_are_written_beside_each_input(wav, tmp_path, ffmpeg, in
invoke("process", *sources, "--no-denoise")
for source in sources:
assert {path.name for path in source.parent.iterdir()} == {
- "take.wav", "take.natural.wav", "take.natural.report.json"}
+ "take.wav", "take.natural.wav", "logs"}
captured = capsys.readouterr()
assert captured.out == ""
assert captured.err.count("Written:") == 2
@@ -240,8 +227,8 @@ def test_preview_default_output_is_written_beside_input(wav, tmp_path, ffmpeg, i
invoke("preview", source, "--no-denoise", "--start", "1", "--duration", "2",
"--profiles", "natural")
assert {path.name for path in tmp_path.iterdir()} == {
- "input.wav", "input.natural.preview.wav", "input.natural.preview.report.json"}
- report = json.loads((tmp_path / "input.natural.preview.report.json").read_text())
+ "input.wav", "input.natural.preview.wav", "logs"}
+ report = json.loads(pipeline.report_for(tmp_path / "input.natural.preview.wav").read_text())
assert report["settings"]["profile"] == "natural"
assert source.read_bytes() == original
@@ -275,7 +262,8 @@ def test_nonfile_output_with_overwrite_fails_before_tool_setup(
source = wav()
original = source.read_bytes()
target = tmp_path / "master.wav"
- nonfile = target.with_suffix(suffix)
+ nonfile = target.with_suffix(suffix) if suffix != ".report.json" else pipeline.report_for(target)
+ nonfile.parent.mkdir(parents=True, exist_ok=True)
nonfile.mkdir()
bypass.mp3 = True
monkeypatch.setattr(pipeline, "ensure_ffmpeg", lambda: pytest.fail("Non-file output reached FFmpeg"))
@@ -283,5 +271,8 @@ def test_nonfile_output_with_overwrite_fails_before_tool_setup(
pipeline.process(source, target, bypass, progress, overwrite=True)
assert nonfile.is_dir()
assert list(nonfile.iterdir()) == []
- assert set(tmp_path.iterdir()) == {source, nonfile}
+ if suffix == ".report.json":
+ assert {path.name for path in tmp_path.iterdir()} == {source.name, "logs"}
+ else:
+ assert set(tmp_path.iterdir()) == {source, nonfile}
assert source.read_bytes() == original