Skip to content

Commit d0add27

Browse files
committed
refactor: remove verbose AI-generated comments from tests
1 parent 9d2f638 commit d0add27

3 files changed

Lines changed: 4 additions & 52 deletions

File tree

tests/integration/test_recording_flow.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
@pytest.mark.asyncio
1616
async def test_transcribe_audio_success(tmp_path: Path) -> None:
1717
"""Test successful transcription with mocked OpenAI API."""
18-
# Create sample audio file
1918
audio_data = np.random.randn(16000).astype(np.float32) * 0.5
2019
wav_path = save_audio_to_wav(audio_data)
2120

2221
try:
23-
# Mock the OpenAI API response
2422
with patch("shh.adapters.whisper.client.AsyncOpenAI") as mock_client:
2523
mock_transcription = MagicMock()
2624
mock_transcription.text = "Hello, this is a test transcription."
@@ -30,7 +28,6 @@ async def test_transcribe_audio_success(tmp_path: Path) -> None:
3028
return_value=mock_transcription
3129
)
3230

33-
# Call transcribe_audio
3431
result = await transcribe_audio(
3532
audio_file_path=wav_path,
3633
api_key="sk-test-key",
@@ -127,20 +124,17 @@ async def test_format_transcription_with_translation() -> None:
127124
)
128125

129126
assert result.text == "Hello, this is a test."
130-
# Verify translation was requested in prompt
131127
call_args = mock_agent.run.call_args
132128
assert "English" in call_args[0][0]
133129

134130

135131
@pytest.mark.asyncio
136132
async def test_full_pipeline_mock(tmp_path: Path) -> None:
137133
"""Test the complete pipeline: audio → transcribe → format."""
138-
# Create sample audio
139134
audio_data = np.random.randn(16000).astype(np.float32) * 0.5
140135
wav_path = save_audio_to_wav(audio_data)
141136

142137
try:
143-
# Mock Whisper API
144138
with patch("shh.adapters.whisper.client.AsyncOpenAI") as mock_whisper:
145139
mock_transcription = MagicMock()
146140
mock_transcription.text = "Um, this is a test transcription."
@@ -150,11 +144,9 @@ async def test_full_pipeline_mock(tmp_path: Path) -> None:
150144
return_value=mock_transcription
151145
)
152146

153-
# Step 1: Transcribe
154147
raw_text = await transcribe_audio(wav_path, "sk-test-key")
155148
assert raw_text == "Um, this is a test transcription."
156149

157-
# Mock PydanticAI for formatting
158150
with (
159151
patch("shh.adapters.llm.formatter.OpenAIChatModel"),
160152
patch("shh.adapters.llm.formatter.Agent") as mock_agent_class,
@@ -166,7 +158,6 @@ async def test_full_pipeline_mock(tmp_path: Path) -> None:
166158
mock_agent.run = AsyncMock(return_value=mock_result)
167159
mock_agent_class.return_value = mock_agent
168160

169-
# Step 2: Format
170161
formatted = await format_transcription(
171162
raw_text,
172163
style=TranscriptionStyle.CASUAL,

tests/unit/adapters/audio/test_processor.py

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,123 +24,87 @@ def sample_audio_data() -> NDArray[np.float32]:
2424

2525
def test_save_audio_to_wav_creates_file(sample_audio_data: NDArray[np.float32]) -> None:
2626
"""Test that save_audio_to_wav creates a WAV file."""
27-
# Act
2827
wav_path = save_audio_to_wav(sample_audio_data)
2928

3029
try:
31-
# Assert
3230
assert wav_path.exists(), "WAV file should exist"
3331
assert wav_path.suffix == ".wav", "File should have .wav extension"
3432
assert wav_path.stat().st_size > 0, "WAV file should not be empty"
3533
finally:
36-
# Cleanup
3734
if wav_path.exists():
3835
wav_path.unlink()
3936

4037

4138
def test_save_audio_to_wav_correct_sample_rate(sample_audio_data: NDArray[np.float32]) -> None:
4239
"""Test that saved WAV file has correct sample rate."""
43-
# Act
4440
wav_path = save_audio_to_wav(sample_audio_data)
4541

4642
try:
47-
# Read back the WAV file
4843
sample_rate, _ = wavfile.read(wav_path)
49-
50-
# Assert
5144
assert sample_rate == SAMPLE_RATE, f"Sample rate should be {SAMPLE_RATE}Hz"
5245
finally:
53-
# Cleanup
5446
if wav_path.exists():
5547
wav_path.unlink()
5648

5749

5850
def test_save_audio_to_wav_correct_data_conversion(sample_audio_data: NDArray[np.float32]) -> None:
5951
"""Test that audio data is correctly converted from float32 to int16."""
60-
# Act
6152
wav_path = save_audio_to_wav(sample_audio_data)
6253

6354
try:
64-
# Read back the WAV file
6555
_, audio_int16 = wavfile.read(wav_path)
66-
67-
# Assert
6856
assert audio_int16.dtype == np.int16, "Audio data should be int16"
6957

70-
# Convert back to float32 for comparison
7158
audio_float_reconstructed = audio_int16.astype(np.float32) / 32767.0
7259

73-
# Check that values are approximately equal (allowing for conversion loss)
74-
# Tolerance is relatively high because int16 has lower precision than float32
7560
np.testing.assert_allclose(
7661
audio_float_reconstructed,
7762
sample_audio_data,
7863
atol=1e-4,
7964
err_msg="Reconstructed audio should match original (within conversion tolerance)",
8065
)
8166
finally:
82-
# Cleanup
8367
if wav_path.exists():
8468
wav_path.unlink()
8569

8670

8771
def test_save_audio_to_wav_custom_sample_rate() -> None:
8872
"""Test that custom sample rate is respected."""
89-
# Arrange
90-
custom_rate = 44100 # CD quality
91-
duration = 0.5 # seconds
73+
custom_rate = 44100
74+
duration = 0.5
9275
samples = int(custom_rate * duration)
93-
audio_data = np.random.randn(samples).astype(np.float32) * 0.5 # Random audio
76+
audio_data = np.random.randn(samples).astype(np.float32) * 0.5
9477

95-
# Act
9678
wav_path = save_audio_to_wav(audio_data, sample_rate=custom_rate)
9779

9880
try:
99-
# Read back
10081
sample_rate, _ = wavfile.read(wav_path)
101-
102-
# Assert
10382
assert sample_rate == custom_rate, f"Sample rate should be {custom_rate}Hz"
10483
finally:
105-
# Cleanup
10684
if wav_path.exists():
10785
wav_path.unlink()
10886

10987

11088
def test_save_audio_to_wav_handles_empty_array() -> None:
11189
"""Test that empty audio array raises an error or handles gracefully."""
112-
# Arrange
11390
empty_audio = np.array([], dtype=np.float32)
114-
115-
# Act & Assert
116-
# scipy should handle this, but let's verify it doesn't crash
11791
wav_path = save_audio_to_wav(empty_audio)
11892

11993
try:
12094
assert wav_path.exists(), "Should create file even for empty audio"
12195
finally:
122-
# Cleanup
12396
if wav_path.exists():
12497
wav_path.unlink()
12598

12699

127100
def test_save_audio_to_wav_handles_large_values() -> None:
128101
"""Test that audio values outside [-1.0, 1.0] are clipped correctly."""
129-
# Arrange - audio with values outside normal range
130-
audio_data = np.array([0.5, 1.5, -1.5, 0.0], dtype=np.float32) # Some values > 1.0
131-
132-
# Act
102+
audio_data = np.array([0.5, 1.5, -1.5, 0.0], dtype=np.float32)
133103
wav_path = save_audio_to_wav(audio_data)
134104

135105
try:
136-
# Read back
137106
_, audio_int16 = wavfile.read(wav_path)
138-
139-
# Assert - values should be converted (may overflow/clip)
140107
assert audio_int16.dtype == np.int16
141-
# Note: Values > 1.0 will cause overflow in int16 conversion
142-
# This is expected behavior - caller should ensure normalized audio
143108
finally:
144-
# Cleanup
145109
if wav_path.exists():
146110
wav_path.unlink()

tests/unit/cli/test_commands.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ def get_test_config_path(cls: type) -> Path:
3434
classmethod(get_test_config_path),
3535
)
3636

37-
# Simulate user input
3837
result = runner.invoke(app, ["setup"], input="sk-test-key-12345678\n")
3938

4039
assert result.exit_code == 0
4140
assert "Setup Complete" in result.stdout
4241
assert "sk-***5678" in result.stdout
4342

44-
# Verify file was saved
4543
assert config_file.exists()
4644
settings = Settings.load_from_file()
4745
assert settings is not None
@@ -82,7 +80,6 @@ def test_config_set_valid(mock_settings: Settings) -> None:
8280
assert result.exit_code == 0
8381
assert "Updated default_style = casual" in result.stdout
8482

85-
# Verify it was saved
8683
settings = Settings.load_from_file()
8784
assert settings is not None
8885
assert settings.default_style == TranscriptionStyle.CASUAL

0 commit comments

Comments
 (0)