File size: 1,062 Bytes
2e818da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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"