Spaces:
Running on Zero
Running on Zero
Download tests/test_api.py from omargam220/PlotCraft: direct link, hf CLI and curl.
- Browser
- Download file 646 Bytes
-
https://huggingface.co/spaces/omargam220/PlotCraft/resolve/main/tests/test_api.py
- Command line
-
hf download hf://spaces/omargam220/PlotCraft/tests/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/omargam220/PlotCraft/resolve/main/tests/test_api.py
646 Bytes
| from fastapi.testclient import TestClient | |
| from api.main import app | |
| client = TestClient(app) | |
| def test_health_endpoint(): | |
| response = client.get("/health") | |
| assert response.status_code == 200 | |
| assert response.json() == {"status": "healthy"} | |
| def test_generate_endpoint(): | |
| response = client.post( | |
| "/generate", | |
| json={"prompt": "Create a bar chart"}, | |
| ) | |
| assert response.status_code == 200 | |
| assert "matplotlib" in response.json()["generated_code"] | |
| def test_generate_endpoint_rejects_blank_prompt(): | |
| response = client.post("/generate", json={"prompt": " "}) | |
| assert response.status_code == 400 | |