Files
Emil Shanaty 0cfb4277b5 aicc-py 0.1.0: initial SDK
- protocol.py: pydantic models for all AICC message types (envelope,
  session_init, tool_call, tool_result, event, error, heartbeat)
- bridge.py: Bridge with @bridge.tool registration, capability checks,
  session management, serve_forever
- client.py: AICCClient with single background reader (safe on
  concurrent transports like WebSocket), call_tool, events, manifest
- tool.py: @tool decorator with schema generation from type hints
- schema.py: JSON Schema generation (str/int/float/bool, list, dict,
  Optional, pydantic models)
- transport: Transport protocol, InProcessTransport, WebSocket client+server
- tests: 12 passing (integration, schema, websocket roundtrip)
- examples: bridge_minimal.py + agent_minimal.py (verified end-to-end)
2026-08-08 03:10:35 +03:00

58 lines
1.5 KiB
Python

"""Schema unit tests: function_schema and return_schema."""
from aicc.schema import function_schema, return_schema
def test_basic_types():
def fn(a: int, b: str, c: float = 1.0) -> dict: ...
s = function_schema(fn)
assert s["type"] == "object"
assert s["properties"]["a"]["type"] == "integer"
assert s["properties"]["b"]["type"] == "string"
assert s["properties"]["c"]["type"] == "number"
assert set(s["required"]) == {"a", "b"}
def test_list_and_dict():
def fn(items: list[int], mapping: dict[str, float]) -> dict: ...
s = function_schema(fn)
assert s["properties"]["items"]["type"] == "array"
assert s["properties"]["items"]["items"]["type"] == "integer"
assert s["properties"]["mapping"]["type"] == "object"
def test_optional():
def fn(x: int | None = None) -> dict: ...
s = function_schema(fn)
assert s["properties"]["x"]["nullable"] is True
assert "x" not in s["required"]
def test_pydantic_model_as_root_input():
from pydantic import BaseModel
class Input(BaseModel):
x: int
y: str
def fn(data: Input) -> dict: ...
s = function_schema(fn)
assert "properties" in s
assert "x" in s["properties"]
assert "y" in s["properties"]
def test_return_schema_basic():
def fn() -> int: ...
assert return_schema(fn)["type"] == "integer"
def g() -> list[str]: ...
assert return_schema(g)["type"] == "array"
def h() -> dict: ...
assert return_schema(h)["type"] == "object"