from __future__ import annotations import shutil import wave import pytest from app.services.ffprobe_service import FFprobeService @pytest.mark.skipif(shutil.which("ffprobe") is None, reason="ffprobe is not installed") async def test_ffprobe_returns_audio_metadata(settings, tmp_path) -> None: audio = tmp_path / "tone.wav" with wave.open(str(audio), "wb") as stream: stream.setnchannels(1) stream.setsampwidth(2) stream.setframerate(8000) stream.writeframes(b"\x00\x00" * 8000) metadata = await FFprobeService(settings).probe(audio) assert metadata["duration"] == pytest.approx(1.0, abs=0.01) assert metadata["audio_streams"][0]["codec"] == "pcm_s16le"