File size: 1,135 Bytes
673435a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
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")