import io import json import zipfile from conftest import complete from ros_fixtures import INTERFACES, as_file_blocks, python_package from api.ros_check import load_interfaces def test_app_page_and_assets_are_served(run_env): client = run_env[0] page = client.get("/") assert page.status_code == 200 and "RosDiff" in page.text and "/static/app/app.js" in page.text assert client.get("/static/app/app.js").status_code == 200 assert client.get("/static/app/app.css").status_code == 200 def test_history_generation_and_media(run_env): client, keys_, backend, services, gen_id = run_env h = {"X-API-Key": keys_["alice"]} hist = client.get("/me/history", headers=h).json() assert hist["tester"] == "alice" and hist["items"][0]["id"] == gen_id assert hist["items"][0]["kind"] == "simulate" and hist["items"][0]["title"].startswith("G1 near a slope") assert client.get("/me/history", headers={"X-API-Key": keys_["bob"]}).json()["items"] == [] run_id = client.post("/simulate/run", json={"generation_id": gen_id}, headers=h).json()["run_id"] complete(backend, "job-1", run_id) job = client.get(f"/jobs/{run_id}", headers=h).json() assert job["media"]["video"].endswith(f"runs/{run_id}/video.mp4") and "video_webm" in job["media"] g = client.get(f"/generations/{gen_id}", headers=h).json() assert g["kind"] == "simulate" and g["valid"] and "