diff --git a/isr.py b/isr.py index 4b05ec0..2779131 100644 --- a/isr.py +++ b/isr.py @@ -54,7 +54,7 @@ class AudioDevice: name: str # Human-readable name channels: int # Max input channels sample_rate: int # Default sample rate - backend: str # Backend name (pulseaudio, pipewire, portaudio) + backend: str # Backend name ('alsa') is_default: bool = False # Is system default is_monitor: bool = False # Is a monitor/loopback source description: str = "" # Extended description diff --git a/tests/test_isr.py b/tests/test_isr.py index 95a9e91..d87e2af 100644 --- a/tests/test_isr.py +++ b/tests/test_isr.py @@ -4,15 +4,13 @@ Tests for isr.py Run with: pytest tests/ """ -import io import logging import struct import wave from datetime import datetime from pathlib import Path -from types import SimpleNamespace from typing import List -from unittest.mock import MagicMock, patch, call +from unittest.mock import MagicMock, patch import pytest @@ -571,50 +569,6 @@ class TestStreamRecorderRecord: ) return r - def test_mp3_chunks_written_to_file(self, tmp_path): - chunks = [b"A" * 512, b"B" * 512, b"C" * 512] - rec = self._recorder(fmt="mp3") - rec.output_dir = str(tmp_path) - - mock_resp = MagicMock() - mock_resp.headers = {"Content-Type": "audio/mpeg"} - mock_resp.iter_content.return_value = iter(chunks) - - def _stop_after_connect(*args, **kwargs): - rec.running = True - return mock_resp - - with patch.object(rec, "connect_stream", side_effect=[mock_resp, None]): - # connect_stream returns the mocked response on the first call; - # we stop the loop via a side-effectful iter_content - original_iter = mock_resp.iter_content.return_value - - def _chunks_then_stop(chunk_size=8192): - for c in chunks: - yield c - rec.running = False # stop the outer while loop - - mock_resp.iter_content.side_effect = _chunks_then_stop - mock_resp.headers = {"Content-Type": "audio/mpeg"} - rec.detected_format = "mp3" - rec.running = True - rec.header_capture_complete = True - rec.stream_headers = None - - # Open a file manually so we can verify writes - filename = rec.generate_filename("mp3") - rec.current_file = open(filename, "wb") - rec.current_filename = filename - - # Simulate one inner loop iteration - for chunk in _chunks_then_stop(): - if chunk: - rec.current_file.write(chunk) - rec.close_current_file() - - written = Path(filename).read_bytes() - assert written == b"A" * 512 + b"B" * 512 + b"C" * 512 - def test_connection_failure_retries(self, tmp_path): rec = self._recorder() rec.output_dir = str(tmp_path)