AIMLxDIV commited on
Commit
9eb1b4f
Β·
1 Parent(s): 74df718

chore : added testcase

Browse files
Files changed (2) hide show
  1. tests/test_api.py +16 -0
  2. tests/test_env.py +8 -1
tests/test_api.py CHANGED
@@ -106,6 +106,22 @@ def test_api_full_workflow_all_tasks(client, task_id):
106
  assert step.status_code == 200
107
  assert step.json()["done"] is True
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  def test_api_leaderboard_pagination(client):
110
  # Submit 3 entries
111
  for i, score in enumerate([0.9, 0.7, 0.5]):
 
106
  assert step.status_code == 200
107
  assert step.json()["done"] is True
108
 
109
+ def test_api_state_endpoint(client):
110
+ reset = client.post("/reset", json={"task_id": "bug_detection", "seed": 1})
111
+ episode_id = reset.json()["episode_id"]
112
+
113
+ # Test state retrieval
114
+ state_resp = client.get(f"/state/{episode_id}")
115
+ assert state_resp.status_code == 200
116
+ state_data = state_resp.json()
117
+ assert "observation" not in state_data # Pydantic model unwrapped
118
+ assert state_data["task_id"] == "bug_detection"
119
+ assert "max_steps" in state_data
120
+
121
+ # Test invalid state
122
+ invalid_state = client.get("/state/invalid-id")
123
+ assert invalid_state.status_code == 404
124
+
125
  def test_api_leaderboard_pagination(client):
126
  # Submit 3 entries
127
  for i, score in enumerate([0.9, 0.7, 0.5]):
tests/test_env.py CHANGED
@@ -27,7 +27,14 @@ def test_env_reset_populates_blast_radius():
27
  assert obs.step_count == 0
28
 
29
 
30
- # ─────────────────────────────────────────────────────────────────────────────
 
 
 
 
 
 
 
31
  # Step tests
32
  # ─────────────────────────────────────────────────────────────────────────────
33
 
 
27
  assert obs.step_count == 0
28
 
29
 
30
+ def test_env_state():
31
+ """Test the python interface state method."""
32
+ env = CodeLensEnv()
33
+ res = env.reset(TaskId.BUG_DETECTION, seed=0)
34
+ state_obs = env.state()
35
+ assert state_obs.task_id == TaskId.BUG_DETECTION
36
+ assert state_obs.step_count == 0
37
+ assert state_obs.noise_budget == 5# ─────────────────────────────────────────────────────────────────────────────
38
  # Step tests
39
  # ─────────────────────────────────────────────────────────────────────────────
40