Skip to main content

Pytest plugin + helpers for testing Anna Executa stdio JSON-RPC plugins.

Project description

anna-executa-test

Pytest plugin and helpers for testing Anna Executa stdio JSON-RPC tool plugins.

Companion to @anna/cli and @anna/app-test — covers the plugin side of an Anna App while @anna/app-test covers the bundle side.

Install

uv pip install anna-executa-test
# or
pip install anna-executa-test

Usage

Drop a tests/test_smoke.py next to your plugin:

from pathlib import Path
import pytest
from anna_executa_test import describe_plugin, executa, assert_jsonrpc_ok

PLUGIN_DIR = Path(__file__).parent.parent

@pytest.fixture(scope="module")
def plugin():
    with executa.spawn(PLUGIN_DIR) as p:
        yield p

def test_describe(plugin):
    info = plugin.call("describe")
    assert info["name"].startswith("tool-")
    assert info["tools"], "plugin should declare at least one tool"

def test_invoke_get_state(plugin):
    resp = plugin.call("invoke", {"tool": "session", "arguments": {"action": "get_state"}})
    assert resp["success"] is True

Public API (Phase 5 MVP)

  • executa.spawn(project_dir, *, command=None, env=None) — context manager spawning the plugin under uv run. Returns ExecutaClient.
  • ExecutaClient.call(method, params=None, *, timeout=10.0) — one JSON-RPC request/response round-trip.
  • ExecutaClient.invoke(tool, arguments) — sugar for the common case.
  • ExecutaClient.describe() / .health() — sugar for the standard control methods.
  • assert_jsonrpc_ok(resp) / assert_jsonrpc_error(resp, code=...)
  • wire_format.validate_response(env) — strict envelope shape check matching nexus.executa_wire.
  • contract.contract_for(project_dir) — read pyproject.toml + spawn briefly to capture MANIFEST; exposes .parametrize_invoke(...).
  • mock_state_dir(tmp_path) — pytest fixture overriding XDG_STATE_HOME and friends.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anna_executa_test-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anna_executa_test-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file anna_executa_test-0.1.0.tar.gz.

File metadata

  • Download URL: anna_executa_test-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for anna_executa_test-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eccb5273633f81d57c9ebdf49e533876e0408ec04317c1e264bb93d0d7dc5fe3
MD5 f1bb6d8549432aa99dfa9e7348593535
BLAKE2b-256 8245c863009300fb346a21de9ed0c389bbdc798ae0c63e2a84d8d4d4d3b8bac2

See more details on using hashes here.

File details

Details for the file anna_executa_test-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for anna_executa_test-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b08269089bed38ed309f87ceeca6400c460f32fdebfca6edc48c0dae8a71ae2
MD5 8f7135d0eab67029793291b63b970818
BLAKE2b-256 520494036fd4838edb3247fbe79f77a2c956a7baa7d8d2e30fe2ef325c86bbd8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page