File size: 1,804 Bytes
8986c3d d552b93 8986c3d d552b93 8986c3d d552b93 8986c3d d552b93 8986c3d d552b93 8986c3d | 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 | from fastapi.testclient import TestClient
from app.main import app
def test_models_is_public_by_default() -> None:
with TestClient(app) as client:
response = client.get("/v1/models")
assert response.status_code == 200
def test_models_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/models", headers={"Authorization": "Bearer changeme"}
)
assert response.status_code == 200
ids = [item["id"] for item in response.json()["data"]]
assert "supertonic-2" in ids
assert "kitten-tts-micro-0.8" in ids
assert "kokoro" in ids
def test_voices_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/voices", headers={"Authorization": "Bearer changeme"}
)
assert response.status_code == 200
aliases = {item["alias"] for item in response.json()["data"]}
assert "alloy" in aliases
assert "atlas" in aliases
assert "grace" in aliases
def test_kitten_voices_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/voices?model=kitten-tts-micro-0.8",
headers={"Authorization": "Bearer changeme"},
)
assert response.status_code == 200
rows = response.json()["data"]
assert {item["alias"] for item in rows} >= {"bella", "jasper", "luna"}
def test_kokoro_voices_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/voices?model=kokoro", headers={"Authorization": "Bearer changeme"}
)
assert response.status_code == 200
rows = response.json()["data"]
assert any(item["model"] == "kokoro" for item in rows)
assert all(item["alias"].startswith(("af", "am", "bf", "bm")) for item in rows)
|