feat: add Android task file evidence and finalize plugin design

This commit is contained in:
chenmingxuan committed 2026-10-15 18:27:11 +08:00
1 parent 96fedc816f
commit 72ff342605
20 files changed
+1005 -35

No files matched your search

@@ -988,6 +988,10 @@ def test_task_material_zip_contains_ordered_evidence_and_reports(
):
job = isolated.jobs(service.create_batch(payload())["id"])[0]
isolated.save_job({**job, "case": {**job["case"], "case_id": "1.1"}})
artifact_dir = reports.TRACES_PATH / job["session_id"] / "artifacts" / "android"
artifact_dir.mkdir(parents=True)
(artifact_dir / "安卓截图.png").write_bytes(b"native png")
(artifact_dir / ".artemis-partial.tmp").write_bytes(b"incomplete")
evidence = tmp_path / "evidence"
evidence.mkdir()
first = evidence / "first.png"
@@ -1015,9 +1019,37 @@ def test_task_material_zip_contains_ordered_evidence_and_reports(
assert archive.read("1.1/任务录屏/0001_recording.mp4") == b"recording.mp4"
manifest = json.loads(archive.read("1.1/文件清单.json"))
assert manifest["session_id"] == job["session_id"]
assert manifest["artifacts"] == ["安卓截图.png"]
assert archive.read("1.1/任务文件/安卓/安卓截图.png") == b"native png"
assert not any("partial" in name for name in files)
assert "1.1-all.zip" in response.headers["content-disposition"]
def test_batch_zip_contains_each_tasks_android_artifacts(isolated):
batch = service.create_batch(payload())
for index, job in enumerate(isolated.jobs(batch["id"])):
root = reports.TRACES_PATH / job["session_id"] / "artifacts" / "android"
root.mkdir(parents=True)
(root / "结果.txt").write_text(f"任务{index}", encoding="utf-8")
with zipfile.ZipFile(reports.export_batch(batch["id"])) as archive:
names = [name for name in archive.namelist() if name.endswith("任务文件/安卓/结果.txt")]
assert len(names) == 2
assert {archive.read(name).decode() for name in names} == {"任务0", "任务1"}
def test_android_artifact_export_does_not_follow_other_session_links(isolated):
root = reports.TRACES_PATH / "session" / "artifacts"
root.mkdir(parents=True)
other = reports.TRACES_PATH / "other-session"
other.mkdir()
(other / "private.txt").write_text("other task")
try:
(root / "android").symlink_to(other, target_is_directory=True)
except OSError:
pytest.skip("symlinks unavailable")
assert reports.session_artifacts({"id": "session"}) == []
def test_video_export_accepts_finalized_worker_trace_and_rejects_external_path(
isolated, tmp_path, monkeypatch
):