-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_process_audio.py
More file actions
65 lines (52 loc) · 2.1 KB
/
Copy pathverify_process_audio.py
File metadata and controls
65 lines (52 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import sys
from fastapi.testclient import TestClient
from unittest.mock import MagicMock, patch
from stt.STT_interface import STTResult
# Add server directory to path to import main
sys.path.append(os.path.join(os.getcwd(), 'synapse-server'))
# Import app from main
from main import app
client = TestClient(app)
def test_process_audio_pipeline():
# Mock STT result
mock_stt_result = STTResult(
full_text="이번 프로젝트의 예산은 500만원입니다. 다음 주까지 기획안을 제출해주세요.",
segments=[],
duration=10.0
)
# Mock Analysis results
mock_structure = {
"action_items": [
{"task": "기획안 제출", "assignee": "전체", "due_date": "다음 주"}
],
"suggestions": ["예산 증액 검토"]
}
mock_summary = "프로젝트 예산 및 일정 논의"
# Patch the functions in main module
with patch('main.transcribe_audio_file', return_value=mock_stt_result) as mock_stt, \
patch('main.analyze_action_items', return_value=mock_structure) as mock_analyze, \
patch('main.generate_summary', return_value=mock_summary) as mock_summarize, \
patch('main.save_and_index_analysis') as mock_save:
# Create a dummy file
with open("test_audio.mp3", "wb") as f:
f.write(b"dummy audio content")
with open("test_audio.mp3", "rb") as f:
response = client.post(
"/api/process_audio",
files={"file": ("test_audio.mp3", f, "audio/mpeg")}
)
# Cleanup
os.remove("test_audio.mp3")
print("Status Code:", response.status_code)
print("Response JSON:", response.json())
if response.status_code == 200:
data = response.json()
if data['raw_script'] == mock_stt_result.full_text:
print("SUCCESS: Pipeline verification passed.")
else:
print("FAILURE: raw_script mismatch.")
else:
print("FAILURE: API returned error.")
if __name__ == "__main__":
test_process_audio_pipeline()