from __future__ import annotations import pytest from somafm_tui import macos_tap def test_osstatus_decodes_four_character_codes() -> None: # 'who?' is kAudioHardwareBadObjectError. assert macos_tap._osstatus(int.from_bytes(b"who?", "big")) == "'who?'" assert macos_tap._osstatus(-50) == "-50" def test_start_raises_without_the_native_api(monkeypatch) -> None: monkeypatch.setattr(macos_tap, "available", lambda: False) tap = macos_tap.SystemAudioTap() with pytest.raises(macos_tap.TapError): tap.start() assert tap.running is False tap.stop() # tearing down a tap that never started is safe def test_read_returns_none_when_not_running() -> None: tap = macos_tap.SystemAudioTap() assert tap.read(0.0) is None def test_uses_no_external_helpers() -> None: # The tap must never shell out: no helper binary, no ffmpeg, no driver. import inspect source = inspect.getsource(macos_tap).casefold() assert "subprocess" not in source assert "avfoundation" not in source