Skip to content

feat(plugins): add plugin test kit #492

Closed

Description

@uniqueg

Problem

Plugin authors (monorepo foca-plugins, third parties) need to test
their plugins without an app, database or network, and the monorepo CI
needs one contract that every plugin must meet.

Proposal

foca.plugins.testing (framework-free):

  • PluginHarness(PluginClass, config=..., api="tes", validate=...):
    runs single hooks or whole pipelines through the real engine.
  • Builders: make_principal, make_inbound(payload, ...),
    make_backend(id, url, labels=...), make_outbound(...),
    make_response(...).
  • FakeHttp: a stand-in for ctx.http that records calls, returns
    canned responses and enforces the deadline.
  • Contract checks check_plugin_contract(PluginClass, ...) (also as a
    pytest plugin module): entry point loads; metadata complete (apis,
    phases, capabilities descriptors valid, maturity,
    api_version); Config/Params export JSON Schema; hooks don't touch
    ctx.original; failed hooks leave the input unchanged; route returns
    a subset; record() within limits; no framework imports; concurrency
    smoke test (one instance, 20 threads).
  • Entry-point fixture for app tests: a pytest fixture (e.g.
    fake_plugin_entry_points) that registers fake plugins as entry points
    of group foca.plugins by patching the loader's entry-point lookup,
    so apps (proTES) test the real allowlist path without a test-only
    distribution; production code has no bypass.
  • Plugin author guide (docs): writing, registering, testing,
    releasing a plugin; rules (thread safety, ctx.state, no personal
    data in record(), descriptors).

Acceptance criteria

  • The kit tests FOCA's own foca.routing.ordered and example plugins
    in FOCA's test suite.
  • Contract failures give actionable messages.
  • The entry-point fixture is used by FOCA's own engine tests and
    restores the lookup afterwards.
  • 100% coverage, mypy, ruff, mkdocs build --strict.

Surviving the Connexion 3 migration

No framework objects (does not need H1-S draft D's foca.testing, which
moved to v0.19.0). With P8 the harness also awaits async def hooks;
existing tests keep working.

Dependencies

Open questions

  • None.

Activity

  1. added this to the v0.18.0 milestone on Oct 24, 2026
  2. added
    priority: high
    status: blocked
    type: feature
    type: testing
    workload: days
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: highstatus: blockedtype: featuretype: testingworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions