test(03-01): fix state recording test mock behavior

- Fix test_state_recording_failure to use correct mock pattern
- _try_official_subtitle returning None triggers _Whisper` fallback
- Ensure proper exception propagation for accurate failure recording

- All 22 tests passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 19:27:21 +08:00
parent 406c6cbbc6
commit 6b3fae3543
+3 -2
View File
@@ -575,7 +575,8 @@ class TestStateRecording:
processor = ASRProcessor(state_manager=mock_state_manager)
mock_state_manager.load.return_value = mock_state
with patch.object(processor, "_try_official_subtitle", side_effect=Exception("Network error")):
# _try_official_subtitle 返回 None(无字幕)
with patch.object(processor, "_try_official_subtitle", return_value=None):
with patch.object(processor, "_run_whisper", side_effect=Exception("Whisper error")):
input_data = ASRInput(
content_id="BV1xx",
@@ -583,7 +584,7 @@ class TestStateRecording:
video_path=str(video_path)
)
with pytest.raises(Exception):
with pytest.raises(Exception, match="Whisper error"):
await processor.process(input_data)
# 应该调用 mark_step_failed