voiceforge / backend /tests /unit /test_export.py
lordofgaming
Initial VoiceForge deployment (clean)
673435a
"""
Test Export Service
"""
import pytest
from app.services.export_service import ExportService
from datetime import datetime
SAMPLE_TRANSCRIPT = {
"id": 1,
"text": "Hello world. This is a test.",
"created_at": "2024-01-01 12:00:00",
"duration": 10.5,
"segments": [
{"start_time": 0.0, "end_time": 1.5, "text": "Hello world.", "speaker": "SPEAKER_1"},
{"start_time": 1.5, "end_time": 3.0, "text": "This is a test.", "speaker": "SPEAKER_1"}
],
"sentiment": {"polarity": 0.5, "subjectivity": 0.1}
}
def test_export_txt():
txt = ExportService.to_txt(SAMPLE_TRANSCRIPT)
assert "Transcript ID: 1" in txt
assert "Hello world" in txt
def test_export_srt():
srt = ExportService.to_srt(SAMPLE_TRANSCRIPT)
assert "1" in srt
assert "00:00:00,000 --> 00:00:01,500" in srt
assert "Hello world" in srt
def test_export_vtt():
vtt = ExportService.to_vtt(SAMPLE_TRANSCRIPT)
assert "WEBVTT" in vtt
assert "00:00:00.000 --> 00:00:01.500" in vtt
def test_export_pdf():
pdf_bytes = ExportService.to_pdf(SAMPLE_TRANSCRIPT)
assert pdf_bytes.startswith(b"%PDF")