Spaces:
Sleeping
Sleeping
Download engine/tests/test_server.py from lorcapoul/smol-neuron-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/lorcapoul/smol-neuron-studio/resolve/main/engine/tests/test_server.py
- Command line
-
hf download hf://spaces/lorcapoul/smol-neuron-studio/engine/tests/test_server.py
-
curl -L -o test_server.py https://huggingface.co/spaces/lorcapoul/smol-neuron-studio/resolve/main/engine/tests/test_server.py
1.11 kB
| from fastapi.testclient import TestClient | |
| from app.main import warmup | |
| from app.server import create_app | |
| def test_sirve_la_api_bajo_api_y_la_interfaz_en_la_raiz(tmp_path, loaded): | |
| (tmp_path / "index.html").write_text("<!doctype html><title>studio</title>") | |
| (tmp_path / "_nuxt").mkdir() | |
| (tmp_path / "_nuxt" / "app.js").write_text("console.log(1)") | |
| with TestClient(create_app(tmp_path)) as c: | |
| warmup.run() | |
| assert "studio" in c.get("/").text | |
| assert c.get("/_nuxt/app.js").text == "console.log(1)" | |
| info = c.get("/api/info") | |
| assert info.status_code == 200 and info.json()["model_id"] == loaded.info.model_id | |
| r = c.post("/api/trace", json={"prompt": "Hi"}) | |
| assert r.status_code == 200 and r.content[:4] == b"SNT1" | |
| assert c.get("/info").status_code == 404, "la API ya no vive en la raíz" | |
| def test_sin_interfaz_compilada_queda_solo_la_api(tmp_path, loaded): | |
| with TestClient(create_app(tmp_path / "missing")) as c: | |
| warmup.run() | |
| assert c.get("/api/info").status_code == 200 | |
| assert c.get("/").status_code == 404 | |