Download source/tests/test_api.py from sriharithebest/nayara-v1: direct link, hf CLI and curl.
- Browser
- Download file 878 Bytes
-
https://huggingface.co/sriharithebest/nayara-v1/resolve/main/source/tests/test_api.py
- Command line
-
hf download hf://sriharithebest/nayara-v1/source/tests/test_api.py
-
curl -L -o test_api.py https://huggingface.co/sriharithebest/nayara-v1/resolve/main/source/tests/test_api.py
878 Bytes
| import fastapi | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| import api | |
| def test_health_readiness_and_bearer_auth(monkeypatch): | |
| client = TestClient(api.app) | |
| assert client.get("/healthz").status_code == 200 | |
| assert client.get("/readyz").status_code == 503 | |
| monkeypatch.setenv("NAYARA_API_KEY", "test-secret") | |
| assert client.get("/v1/models").status_code == 401 | |
| response = client.get("/v1/models", headers={"Authorization": "Bearer test-secret"}) | |
| assert response.status_code == 200 | |
| assert response.json()["data"][0]["id"] == "nayara-v1" | |
| def test_chat_prompt_requires_user_message(): | |
| with pytest.raises(fastapi.HTTPException): | |
| api._chat_prompt([api.ChatMessage(role="system", content="Be concise")]) | |
| prompt = api._chat_prompt([api.ChatMessage(role="user", content="hello")]) | |
| assert prompt.endswith("<|assistant|>\n") | |