Spaces:
Sleeping
Sleeping
File size: 1,605 Bytes
711b9b5 06aac03 711b9b5 06aac03 711b9b5 | 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 | """Test OpenEnv API contract compliance."""
import pytest
from openenv_bug_triage import BugTriageEnv
from openenv_bug_triage.models import ActionModel, ClassifyAction
def test_reset_all_tasks():
"""Environment reset should work for all registered tasks."""
env = BugTriageEnv()
for task_id in ["bug_triage_easy", "bug_triage_medium", "bug_triage_hard"]:
obs = env.reset(task_id=task_id, seed=42)
assert obs.current_ticket is not None
assert obs.steps_used == 0
def test_step():
"""Test environment step."""
env = BugTriageEnv()
obs = env.reset(task_id="bug_triage_easy", seed=42)
action = ActionModel(
action_type="classify",
classify=ClassifyAction(
severity="sev2",
priority="p2",
component="api-gateway",
),
)
obs, reward, done, info = env.step(action)
assert -1.0 <= reward.step_reward <= 1.0
assert obs.steps_used == 1
def test_state():
"""Test state retrieval."""
env = BugTriageEnv()
env.reset(task_id="bug_triage_easy", seed=42)
state = env.state()
assert state.current_task_id == "bug_triage_easy"
assert state.episode_done is False
def test_action_model_rejects_mismatched_payloads():
"""Typed actions should reject payloads that do not match the action type."""
with pytest.raises(ValueError):
ActionModel(
action_type="next_ticket",
classify=ClassifyAction(
severity="sev2",
priority="p2",
component="api-gateway",
),
)
|