Download belel_moonshot/tests/test_api.py from TTOPM/belel-protocol: direct link, hf CLI and curl.
- Browser
- Download file 757 Bytes
-
https://huggingface.co/TTOPM/belel-protocol/resolve/main/belel_moonshot/tests/test_api.py
- Command line
-
hf download hf://TTOPM/belel-protocol/belel_moonshot/tests/test_api.py
-
curl -L -o test_api.py https://huggingface.co/TTOPM/belel-protocol/resolve/main/belel_moonshot/tests/test_api.py
757 Bytes
| import base64 | |
| from fastapi.testclient import TestClient | |
| from cloud.api.main import app | |
| client = TestClient(app) | |
| def test_health(): | |
| r = client.get("/healthz"); assert r.status_code==200 | |
| def test_presets(): | |
| r = client.get("/api/presets"); assert r.status_code==200; assert "presets" in r.json() | |
| def test_chat_minimal(monkeypatch): | |
| # Monkeypatch TTS to avoid external call | |
| import cloud.api.tts as tts | |
| def fake_syn(text, t,p,e, voice_name=None, engine=None): return b"RIFF....WAVE" | |
| monkeypatch.setattr(tts, "synthesize", fake_syn) | |
| r = client.post("/api/chat", json={"message":"hello there"}) | |
| assert r.status_code==200 | |
| j=r.json() | |
| assert "response" in j and "voice_base64" in j | |
| base64.b64decode(j["voice_base64"]) | |