Spaces:
Sleeping
Sleeping
File size: 1,410 Bytes
4e663d8 | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | from fastapi.testclient import TestClient
from server.app import app
def test_space_root_redirects_to_openenv_web_ui():
client = TestClient(app)
response = client.get("/", follow_redirects=False)
assert response.status_code == 307
assert response.headers["location"] == "/web/"
def test_openenv_web_ui_and_api_routes_are_available():
client = TestClient(app)
web_response = client.get("/web/")
health_response = client.get("/health")
state_response = client.get("/web/state")
assert web_response.status_code == 200
assert "text/html" in web_response.headers["content-type"]
assert "Reset" in web_response.text
assert "Step" in web_response.text
assert "Get state" in web_response.text
assert health_response.status_code == 200
assert health_response.json() == {"status": "healthy"}
assert state_response.status_code == 200
state = state_response.json()
assert "episode_id" in state
assert "step_count" in state
def test_web_reset_returns_cybersecurity_observation():
client = TestClient(app)
response = client.post("/web/reset")
assert response.status_code == 200
payload = response.json()
observation = payload["observation"]
assert observation["phase"] == "discover"
assert "authorization" in observation["task_brief"]
assert "inspect_policy_graph" in observation["available_actions"]
|