34 lines
1020 B
Python
34 lines
1020 B
Python
from __future__ import annotations
|
|
|
|
from storage.artifact_store import ArtifactStore
|
|
from storage.timeline import Timeline
|
|
from tests.fakes import PNG_10X20
|
|
|
|
|
|
def test_timeline_records_survive_reopening_store(tmp_path) -> None:
|
|
store = ArtifactStore(tmp_path / "history")
|
|
timeline = Timeline(store)
|
|
timeline.append(
|
|
task_id="task-1",
|
|
scene={"screen": {"width": 1, "height": 1}, "elements": []},
|
|
prompt="goal",
|
|
tool_call={"action": "tap"},
|
|
result={"ok": True},
|
|
screenshot=PNG_10X20,
|
|
)
|
|
timeline.append(
|
|
task_id="task-1",
|
|
scene={"screen": {"width": 1, "height": 1}, "elements": []},
|
|
prompt="goal",
|
|
tool_call={"action": "input_text"},
|
|
result={"ok": True},
|
|
screenshot=PNG_10X20,
|
|
)
|
|
|
|
reopened = Timeline(ArtifactStore(tmp_path / "history"))
|
|
records = reopened.read("task-1")
|
|
|
|
assert [record["index"] for record in records] == [1, 2]
|
|
assert records[0]["screenshot_path"].endswith("001.png")
|
|
|