study-buddy / tests /test_sandbox_router.py
GitHub Actions
deploy d092bea3608b7a29952f16357fda39b7a29e399b
2e818da
Raw
History Blame Contribute Delete
1.06 kB
from fastapi.testclient import TestClient
from app.main import app
from app.schemas.graph import HTML5VisualPayload
import app.routers.sandbox as sandbox_router
def test_repair_endpoint_accepts_blank_render_error(monkeypatch):
class FakeTutor:
def repair_visual(self, original_html: str, error_message: str) -> HTML5VisualPayload:
assert error_message.startswith("BlankRender:")
return HTML5VisualPayload(html_code="<html>fixed</html>", animation_type="3d")
monkeypatch.setattr(sandbox_router, "_get_tutor", lambda: FakeTutor())
response = TestClient(app).post(
"/sandbox/repair",
json={
"original_html": "<html>original</html>",
"error_message": "BlankRender: no renderable objects were added within 900ms",
"node_id": "n1",
"animation_type": "3d",
},
)
assert response.status_code == 200
body = response.json()
assert body["visual"]["html_code"] == "<html>fixed</html>"
assert body["visual"]["animation_type"] == "3d"