Spaces:
Sleeping
Sleeping
File size: 2,223 Bytes
5fe93dd | 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent / "backend"))
from fastapi.testclient import TestClient
from backend.main import app
import json
client = TestClient(app)
def validate_openenv():
print("Beginning OpenEnv Specification Validation Pipeline...")
# 1. Test /reset
print("Testing /reset endpoint...")
reset_payload = {
"task": "software-incident",
"seed": 42
}
response = client.post("/reset", json=reset_payload)
if response.status_code != 200:
print(f"FAILED: /reset returned {response.status_code}\n{response.text}")
return False
obs = response.json()
print(" -> /reset returned valid NexusObservation schema.")
# 2. Test /state
print("Testing /state endpoint...")
state_response = client.get("/state")
if state_response.status_code != 200:
print(f"FAILED: /state returned {state_response.status_code}\n{state_response.text}")
return False
print(" -> /state returned valid scenario state.")
# 3. Test /step
print("Testing /step endpoint...")
action_payload = {
"agent_id": "agent_a",
"message": "Testing the tool execution API directly.",
"tool_calls": [
{
"tool_name": "check_service_status",
"params": {"service": "nginx-proxy"}
}
],
"confidence": 0.9
}
step_response = client.post("/step", json=action_payload)
if step_response.status_code != 200:
print(f"FAILED: /step returned {step_response.status_code}\n{step_response.text}")
return False
step_data = step_response.json()
print(" -> /step returned StepResponse (observation, reward, done, info).")
if "reward" not in step_data or "done" not in step_data:
print("FAILED: /step response missing mandatory OpenEnv schema tags.")
return False
print("\n[SUCCESS] Pre-Submission Validation completed successfully. Architecture strictly conforms to the OpenEnv standard.")
return True
if __name__ == "__main__":
success = validate_openenv()
if not success:
exit(1)
|