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.1.tar.gz (11.0 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.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anna_executa_test-0.1.1.tar.gz
  • Upload date:
  • Size: 11.0 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.1.tar.gz
Algorithm Hash digest
SHA256 8a33412a14107dcfd598d20ff1f5a463c3a60b15f9ca901f773ee91aaaa66eaf
MD5 c34dc1738699c5b072212ab6ac56a194
BLAKE2b-256 5d452233aa4b4c0c3d7a37fe8b4594a35a10430463dcef27de1604c077cb473b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for anna_executa_test-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d1b1ab983ae6f65b32f2a8969a16d8a41d46da172da8280960f96c1aa7b8725
MD5 7e1c84739b22b615c8e5274c76907584
BLAKE2b-256 bd25bb50f0c60d494f65e8298786275431a7b839937ea6d77ea59c9d80de9af6

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