chore: remove dead test code and fix stale comment

tests/test_isr.py:
- Remove unused imports: io, SimpleNamespace, call
- Remove test_mp3_chunks_written_to_file — it mocked connect_stream but
  never called record(), making all the mock scaffolding dead; the actual
  assertion (bytes written to a file) is already covered by
  TestAudioFileWriter and TestGenerateFilename

isr.py:
- Update AudioDevice.backend comment: only the ALSA backend exists now

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 23:32:34 +02:00
parent 4aea07ae40
commit 9ba084107b
2 changed files with 2 additions and 48 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ class AudioDevice:
name: str # Human-readable name name: str # Human-readable name
channels: int # Max input channels channels: int # Max input channels
sample_rate: int # Default sample rate 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_default: bool = False # Is system default
is_monitor: bool = False # Is a monitor/loopback source is_monitor: bool = False # Is a monitor/loopback source
description: str = "" # Extended description description: str = "" # Extended description
+1 -47
View File
@@ -4,15 +4,13 @@ Tests for isr.py
Run with: pytest tests/ Run with: pytest tests/
""" """
import io
import logging import logging
import struct import struct
import wave import wave
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from types import SimpleNamespace
from typing import List from typing import List
from unittest.mock import MagicMock, patch, call from unittest.mock import MagicMock, patch
import pytest import pytest
@@ -571,50 +569,6 @@ class TestStreamRecorderRecord:
) )
return r 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): def test_connection_failure_retries(self, tmp_path):
rec = self._recorder() rec = self._recorder()
rec.output_dir = str(tmp_path) rec.output_dir = str(tmp_path)