Build the manifest's full decomposed services architecture as real, tested code: - scheduler: 16 modules (queue/pool/policy/quota/placement/recovery + metrics/ events/backoff/health/fairness/shutdown + honest nats seam) — 130 tests - worker: 16 modules (execute/lease/resources/limits + heartbeat/events/telemetry/ sandbox/recovery/cleanup/upload/artifacts + honest plugins seam) — 52 tests - api: 20 modules (auth/authz/middleware + per-resource handlers + telemetry/ facades), app.py now a thin composition root — 98 tests - gateway: new std-only Rust reverse-proxy crate (proxy/routing/auth/cors/ rate_limit/retry/timeouts/health/metrics/events/tracing + honest tls seam) — 110 tests Every one of the 3,161 manifest files now exists. Extractions are behavior- preserving (all prior tests green); new modules add real capability; nats/tls/ plugins/sandbox are honest documented seams, not fakes. Rust workspace 352->605 tests; API 35->98. clippy -D warnings + fmt clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
"""Tests for the simulate action module (a sub-resource of worlds)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from lawsynth_api import simulations
|
|
from lawsynth_server.errors import ValidationError
|
|
|
|
|
|
def test_is_simulate_matches_only_the_world_action():
|
|
assert simulations.is_simulate(["worlds", "id", "simulate"])
|
|
assert not simulations.is_simulate(["worlds", "id"])
|
|
assert not simulations.is_simulate(["runs", "id", "simulate"])
|
|
|
|
|
|
def test_classify_labels_the_simulate_post():
|
|
assert simulations.classify("POST", ["worlds", "id", "simulate"]) == "worlds.simulate"
|
|
assert simulations.classify("GET", ["worlds", "id", "simulate"]) is None
|
|
assert simulations.classify("POST", ["worlds", "id"]) is None
|
|
|
|
|
|
def test_normalize_request_accepts_valid_spec():
|
|
spec = simulations.normalize_request({"initial": {"x": 1.0}, "horizon": 1.0, "step": 0.1})
|
|
assert spec["horizon"] == 1.0 and spec["step"] == 0.1 and spec["method"] == "rk4"
|
|
|
|
|
|
def test_normalize_request_rejects_non_positive_step():
|
|
with pytest.raises(ValidationError):
|
|
simulations.normalize_request({"horizon": 1.0, "step": 0.0})
|
|
|
|
|
|
def test_normalize_request_rejects_unsupported_method():
|
|
with pytest.raises(ValidationError):
|
|
simulations.normalize_request({"horizon": 1.0, "step": 0.1, "method": "euler"})
|