Files
devplacepy/tests/unit/services/nodes/spec.py
T
retoorandClaude Sonnet 5.5 f55c7ee5f4
DevPlace CI / test (push) Failing after 31m42s
Add community node protocol spec, Agent Skills, and make the failing tests hermetic
Community nodes (Phase 1 of plan.md): the protocol specification in
services/nodes/spec.py as the single source of truth, GET /nodes/spec.json,
a generated protocol docs page, the Community nodes API docs group, and the
implementation plan plus the residential proxy research. The no-open-proxy rule
is enforced in the spec (open_proxy cannot be set).

Agent Skills: register the Skills API docs group, cascade skills on account
deletion, add the nested CLAUDE.md, README and routes docs, and cover the
parser, the fetcher (end to end against a mock origin), the data layer and the
routes with 73 unit and 16 api tests.

Tests made hermetic with the repo's existing patterns instead of ambient
environment: embeddings tests set OPENROUTER_API_KEY via monkeypatch, the
workspace tests install FakeBackend via runtime.set_backend, and the skills
install tests use run_async. DockerCliBackend now returns 127 (command not
found) when the CLI is missing instead of raising FileNotFoundError, so a host
without docker answers with a clean error rather than a 500. The Providers tab
empty state no longer names the Model routes tab.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 07:13:25 +02:00

74 lines
2.2 KiB
Python

# retoor <retoor@molodetz.nl>
import pytest
from devplacepy.services.nodes import spec
from devplacepy.services.nodes.spec import SPEC
def test_open_proxy_is_never_enabled():
assert SPEC.open_proxy is False
assert SPEC.describe()["open_proxy"] is False
def test_ports_are_web_only():
assert spec.ALLOWED_PORTS == (80, 443)
for destination in SPEC.destinations:
assert set(destination.ports) <= {80, 443}
def test_frame_types_unique_per_direction():
seen = [(item.type, item.direction) for item in SPEC.frames]
assert len(seen) == len(set(seen))
def test_every_frame_fits_the_wire_cap():
for item in SPEC.frames:
assert 0 < item.max_bytes <= 3 * 1024 * 1024
assert item.direction in (spec.CLIENT_TO_SERVER, spec.SERVER_TO_CLIENT)
def test_frame_lookup():
assert SPEC.frame("hello", spec.CLIENT_TO_SERVER).required()[0] == "protocol"
assert SPEC.frame("hello", spec.SERVER_TO_CLIENT) is None
assert "type" in SPEC.frame("ping", spec.SERVER_TO_CLIENT).allowed()
@pytest.mark.parametrize(
"host,expected",
[
("reddit.com", True),
("www.reddit.com", True),
("old.reddit.com", True),
("REDDIT.COM.", True),
("evilreddit.com", False),
("reddit.com.evil.net", False),
("localhost", False),
("127.0.0.1", False),
],
)
def test_destination_matching_is_suffix_safe(host, expected):
assert (SPEC.destination(host) is not None) is expected
def test_limits_are_positive_and_ordered():
limits = SPEC.limits
for value in limits.describe().values():
assert value >= 0
assert limits.default_wait_seconds <= limits.max_wait_seconds
assert limits.reconnect_min_seconds <= limits.reconnect_max_seconds
assert limits.cache_entry_max_bytes <= limits.cache_max_bytes
assert limits.default_donor_mb_per_day <= limits.max_donor_mb_per_day
assert limits.job_timeout_seconds <= limits.max_wait_seconds
assert limits.default_daily_requests_guest == 0
def test_protocol_versions_consistent():
assert SPEC.min_supported <= SPEC.version
def test_describe_is_json_serialisable():
import json
json.dumps(SPEC.describe())