61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
|
|
from engine.task_loader import load_task
|
|
|
|
|
|
class TaskLoaderSmokeTest(unittest.TestCase):
|
|
def test_loads_minimal_task(self) -> None:
|
|
task_yaml = """
|
|
id: demo
|
|
description: Demo task
|
|
artifacts:
|
|
include:
|
|
- tasks/demo/sample.txt
|
|
exclude: []
|
|
max_files_per_iteration: 1
|
|
mutation:
|
|
mode: direct_edit
|
|
allowed_file_types: [".txt"]
|
|
max_changed_lines: 10
|
|
runner:
|
|
command: "python -c \\\"print('run')\\\""
|
|
cwd: "."
|
|
timeout_seconds: 10
|
|
scorer:
|
|
type: command
|
|
command: "python -c \\\"import json; print(json.dumps({'score': 1, 'metrics': {'violation_count': 0}}))\\\""
|
|
parse:
|
|
format: json
|
|
score_field: "score"
|
|
metrics_field: "metrics"
|
|
objective:
|
|
primary_metric: score
|
|
direction: maximize
|
|
constraints:
|
|
- metric: violation_count
|
|
op: "<="
|
|
value: 0
|
|
policy:
|
|
keep_if: better_primary
|
|
tie_breakers: []
|
|
on_failure: discard
|
|
budget:
|
|
max_iterations: 3
|
|
max_failures: 1
|
|
logging:
|
|
results_file: work/results.jsonl
|
|
candidate_dir: work/candidates
|
|
"""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
task_path = Path(tmp) / "task.yaml"
|
|
task_path.write_text(task_yaml, encoding="utf-8")
|
|
task = load_task(task_path)
|
|
self.assertEqual(task.id, "demo")
|
|
self.assertEqual(task.objective.direction, "maximize")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|