Spaces:
Sleeping
Sleeping
File size: 1,993 Bytes
339abf5 | 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 | from __future__ import annotations
from fastapi.testclient import TestClient
from server.app import app
client = TestClient(app)
def test_health_contract() -> None:
response = client.get("/health")
assert response.status_code == 200
payload = response.json()
assert payload["status"] == "ok"
assert payload["environment"] == "bug-triage-openenv"
def test_baseline_contract() -> None:
response = client.get("/baseline")
assert response.status_code == 200
payload = response.json()
assert payload["offline_mode"] is True
assert "mean_score" in payload
assert "results" in payload
assert len(payload["results"]) == 3
def test_reset_step_and_state_contract() -> None:
reset_response = client.post("/reset", json={"task_id": "bug_triage_easy", "seed": 42})
assert reset_response.status_code == 200
observation = reset_response.json()
assert "current_ticket" in observation
assert "queue_stats" in observation
assert "steps_used" in observation
assert "steps_remaining" in observation
step_response = client.post(
"/step",
json={"action": {"action_type": "next_ticket", "next_ticket": {}}},
)
assert step_response.status_code == 200
step_payload = step_response.json()
assert set(step_payload.keys()) == {"observation", "reward", "done", "info"}
assert isinstance(step_payload["done"], bool)
state_response = client.get("/state")
assert state_response.status_code == 200
state_payload = state_response.json()
assert "initialized" in state_payload
assert "steps_used" in state_payload
assert "current_task_id" in state_payload
def test_state_before_reset_contract() -> None:
# Ensure endpoint always returns a stable shape even before init in fresh process.
response = client.get("/state")
assert response.status_code == 200
payload = response.json()
assert "initialized" in payload
assert "episode_done" in payload
|