lawsynth/services/api/tests/main_test.py
caelum0x bd58228c14 feat: complete manifest services layer — decomposed modules + Rust gateway
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>
2026-08-17 19:55:26 +03:00

35 lines
869 B
Python

"""Unit tests for the WSGI import target and dev-server CLI guards."""
from __future__ import annotations
import pytest
from lawsynth_api.app import WsgiApplication
from lawsynth_api.main import _loopback, application, main
def test_module_exposes_a_wsgi_application_target():
assert isinstance(application, WsgiApplication)
def test_loopback_recognizes_local_hosts():
assert _loopback("127.0.0.1")
assert _loopback("::1")
assert _loopback("localhost")
def test_loopback_rejects_public_hosts():
assert not _loopback("0.0.0.0")
assert not _loopback("192.168.1.10")
assert not _loopback("example.com")
def test_main_rejects_non_loopback_host():
with pytest.raises(SystemExit):
main(["--host", "0.0.0.0"])
def test_main_rejects_out_of_range_port():
with pytest.raises(SystemExit):
main(["--port", "70000"])