forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_benchmark_tasks.py
More file actions
67 lines (54 loc) 路 2.32 KB
/
Copy pathtest_benchmark_tasks.py
File metadata and controls
67 lines (54 loc) 路 2.32 KB
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
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""Tests for benchmark task catalog schema and references."""
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from misakanet.search.engine import REPO
TASKS_FILE = REPO / "data" / "benchmark_tasks.json"
REQUIRED_FIELDS = {"task_id", "title", "failure", "expected_action", "lesson_ref", "verifier_type"}
VALID_VERIFIERS = {"command_exit", "http_status", "file_content", "log_pattern", "process_alive"}
def _load_tasks():
with open(TASKS_FILE, encoding="utf-8") as f:
return json.load(f)
class TestBenchmarkTasks:
def test_file_exists(self):
assert TASKS_FILE.exists(), f"{TASKS_FILE} not found"
def test_minimum_count(self):
tasks = _load_tasks()
assert len(tasks) >= 10, f"Expected >= 10 tasks, got {len(tasks)}"
def test_unique_ids(self):
tasks = _load_tasks()
ids = [t["task_id"] for t in tasks]
assert len(ids) == len(set(ids)), "Duplicate task_id found"
def test_schema_fields(self):
tasks = _load_tasks()
for task in tasks:
missing = REQUIRED_FIELDS - set(task.keys())
assert not missing, f"Task {task.get('task_id')} missing fields: {missing}"
def test_verifier_type_valid(self):
tasks = _load_tasks()
for task in tasks:
vtype = task.get("verifier_type")
assert vtype in VALID_VERIFIERS, (
f"Invalid verifier_type '{vtype}' in {task.get('task_id')}"
)
def test_no_random_simulated_results(self):
tasks = _load_tasks()
for task in tasks:
assert "random" not in task["failure"].lower()
assert "simulated" not in task["failure"].lower()
assert "fake" not in task["failure"].lower()
assert "random" not in task["expected_action"].lower()
def test_lesson_refs_exist(self):
tasks = _load_tasks()
for task in tasks:
ref = Path(task["lesson_ref"])
assert ref.exists(), f"lesson_ref not found: {ref}"
def test_expected_action_present(self):
tasks = _load_tasks()
for task in tasks:
action = task.get("expected_action", "")
assert len(action) >= 10, (
f"expected_action too short in {task.get('task_id')}"
)