# tests/test_export_service.py — unit tests for export stitch service from __future__ import annotations import pytest @pytest.mark.asyncio async def test_stitch_single_file(tmp_path): """Single file: should copy without invoking ffmpeg.""" from app.services.export import stitch src = tmp_path / "segment.wav" src.write_bytes(b"WAV DATA") out = str(tmp_path / "output.wav") result = await stitch([str(src)], out) assert result == out assert open(out, "rb").read() == b"WAV DATA" @pytest.mark.asyncio async def test_stitch_empty_raises(tmp_path): from app.services.export import stitch with pytest.raises(ValueError, match="No audio paths"): await stitch([], str(tmp_path / "out.wav")) def test_make_export_path(): from app.services.export import make_export_path p = make_export_path("data", "chain-abc", "mp3") assert p == "data/chains/chain-abc/export.mp3" assert make_export_path("data", "chain-abc", "wav").endswith(".wav")