File size: 1,338 Bytes
1aa90a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pytest
from fastapi.testclient import TestClient
from app import app

client = TestClient(app)


def test_health_check():
    """Test health endpoint"""
    response = client.get("/health")
    assert response.status_code == 200
    assert response.json() == {"status": "ok"}


def test_get_voices():
    """Test voices endpoint"""
    response = client.get("/api/voices")
    assert response.status_code == 200
    voices = response.json()
    assert isinstance(voices, list)
    assert "af_heart" in voices
    assert "am_adam" in voices


def test_get_music_tags():
    """Test music tags endpoint"""
    response = client.get("/api/music-tags")
    assert response.status_code == 200
    tags = response.json()
    assert isinstance(tags, list)


def test_list_videos():
    """Test list videos endpoint"""
    response = client.get("/api/short-videos")
    assert response.status_code == 200
    data = response.json()
    assert "videos" in data
    assert isinstance(data["videos"], list)


def test_create_video_invalid_data():
    """Test create video with invalid data"""
    response = client.post("/api/short-video", json={})
    assert response.status_code == 422  # Validation error


# Note: Full integration tests require valid PEXELS_API_KEY and HF_TTS
# Run those separately with proper environment configuration