26 lines
789 B
Python
26 lines
789 B
Python
import asyncio
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
def test_transcription_engine_is_singleton():
|
|
from transcription import engine, TranscriptionEngine
|
|
assert isinstance(engine, TranscriptionEngine)
|
|
|
|
|
|
def test_transcribe_file_calls_whisper(tmp_path):
|
|
wav = tmp_path / "test.wav"
|
|
wav.write_bytes(b"\x00" * 100)
|
|
|
|
mock_model = MagicMock()
|
|
mock_segment = MagicMock()
|
|
mock_segment.text = " Hallo Welt"
|
|
mock_model.transcribe.return_value = ([mock_segment], MagicMock())
|
|
|
|
from transcription import TranscriptionEngine
|
|
eng = TranscriptionEngine()
|
|
eng._model = mock_model
|
|
|
|
result = asyncio.run(eng.transcribe_file(str(wav), language="de"))
|
|
assert result == "Hallo Welt"
|
|
mock_model.transcribe.assert_called_once_with(str(wav), language="de")
|