37 lines
979 B
Python
37 lines
979 B
Python
import json
|
|
import pytest
|
|
from specs.ir import (
|
|
LocalProblem,
|
|
SharedSignals,
|
|
PlanDelta,
|
|
SafetyContract,
|
|
AuditLog,
|
|
AdapterContract,
|
|
)
|
|
|
|
|
|
def test_localproblem_minimal():
|
|
lp = LocalProblem(id="task-1", goal_type="reach")
|
|
assert lp.id == "task-1"
|
|
assert lp.goal_type == "reach"
|
|
|
|
|
|
def test_plan_delta_and_vector_clock():
|
|
pd = PlanDelta(plan_id="p1", timestamp=1.23, patch={"ops": []}, safety_tags=["none"], vector_clock={"a": 1})
|
|
assert pd.vector_clock["a"] == 1
|
|
|
|
|
|
def test_safety_contract_default_fail_action():
|
|
sc = SafetyContract(contract_id="c1")
|
|
assert "halt" in sc.fail_actions
|
|
|
|
|
|
def test_schema_generation_json():
|
|
# ensure schema JSON generation works for all models
|
|
models = [LocalProblem, SharedSignals, PlanDelta, SafetyContract, AuditLog, AdapterContract]
|
|
for m in models:
|
|
s = m.schema()
|
|
# ensure basic JSON-serializable
|
|
json.dumps(s)
|
|
assert "title" in s or "properties" in s
|