idea155-hopemesh-2-0/test.sh

35 lines
1.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
echo "Running tests: build and smoke import/instantiate..."
python3 -m build >/tmp/build.log 2>&1 || {
echo 'Build failed'; tail -n +1 /tmp/build.log; exit 1; }
echo "Smoke test: import modules and create objects..."
python3 - << 'PY'
from hopemesh import GraphOfContracts, GovernanceLedger
from hopemesh.sdk import make_local_problem, make_shared_variables, make_plan_delta, merge_plan_deltas
lp = make_local_problem("RegionA Allocation", region="RegionA")
sv = make_shared_variables("example", {"stock": 100})
pd = make_plan_delta("pd-001", [{"allocate": {"region": "RegionA", "qty": 10}}])
graph = GraphOfContracts()
schema = graph.register_schema("allocation", "1.0", {"fields": ["region", "qty"]})
adapter = graph.register_adapter("regional-hub", "1.0", {"transport": "tls"})
graph.link(adapter.contract_id, schema.contract_id)
ledger = GovernanceLedger()
ledger.append("demo", {"delta": pd.delta_id})
merged = merge_plan_deltas([pd])
print(lp)
print(sv)
print(pd)
print(graph.fingerprint())
print(ledger.verify())
print(merged)
print("OK")
PY
echo "Running unit tests..."
python3 -m unittest discover -s tests -p 'test_*.py'
echo "All tests passed."