File size: 1,640 Bytes
e65a128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239f219
 
e65a128
 
 
 
 
 
 
 
239f219
 
 
 
e65a128
 
 
 
 
 
 
239f219
 
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
from __future__ import annotations

import sys
from pathlib import Path

from fastapi.testclient import TestClient

ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

from app import app


client = TestClient(app)


def test_reset_accepts_empty_body():
    response = client.post("/reset")
    assert response.status_code == 200
    body = response.json()
    assert "episode_id" in body
    assert body["done"] is False
    assert "observation" in body


def test_episode_state_is_isolated():
    first_reset = client.post("/reset", json={"task_name": "refund_triage_easy"})
    second_reset = client.post("/reset", json={"task_name": "cross_function_brief_medium"})
    assert first_reset.status_code == 200
    assert second_reset.status_code == 200

    first_episode = first_reset.json()["episode_id"]
    second_episode = second_reset.json()["episode_id"]
    assert first_episode != second_episode

    first_chunk = first_reset.json()["observation"]["available_chunks"][0]["chunk_id"]
    step = client.post(
        f"/step?episode_id={first_episode}",
        json={"action_type": "inspect_artifact", "artifact_id": first_chunk},
    )
    assert step.status_code == 200
    assert step.json()["episode_id"] == first_episode

    first_state = client.get(f"/state?episode_id={first_episode}")
    second_state = client.get(f"/state?episode_id={second_episode}")
    assert first_state.status_code == 200
    assert second_state.status_code == 200
    assert first_chunk in first_state.json()["reviewed_artifacts"]
    assert second_state.json()["reviewed_artifacts"] == []