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("studio") (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