Skip to content

feat(testing): make_request_context + build_asgi_app helpers#535

Merged
bokelley merged 2 commits into
mainfrom
bokelley/testing-helpers
May 4, 2026
Merged

feat(testing): make_request_context + build_asgi_app helpers#535
bokelley merged 2 commits into
mainfrom
bokelley/testing-helpers

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented May 4, 2026

Closes #516.

Summary

Two adopter-facing test helpers in adcp.testing:

  • make_request_context(account=..., **overrides) — build a RequestContext for unit tests with stable defaults. Default account is Account(id="test-account"); pass a string shorthand for the common case (account="acme").
  • build_asgi_app(platform, name=...) — build a Starlette ASGI app from a DecisioningPlatform without binding a port. Default auto_emit_completion_webhooks=False skips the F12 boot gate so sales platforms construct without wiring webhook infra.

Why

Salesagent migration feedback #10 + #11:

Constructing a RequestContext for tests requires guessing which factory defaults are safe. I hit TypeError: unexpected keyword argument 'adopter_request' when I read a docstring that mentioned the field but it's not a constructor parameter.

Building the ASGI app in tests requires going through create_adcp_server_from_platform() → create_mcp_server() and the kwarg surface differs between the two.

Test plan

  • 11 unit tests in tests/test_testing_decisioning.py:
    • default + string shorthand + Account-instance forms of make_request_context
    • all optional fields thread through correctly
    • default state/resolve use framework v6.0 stubs
    • build_asgi_app returns an ASGI callable, default skips webhook gate, accepts name=, threads advertise_all=, propagates validate_platform errors
  • ruff, mypy, all pre-commit hooks pass

🤖 Generated with Claude Code

bokelley and others added 2 commits May 3, 2026 21:31
Two test-DX helpers in ``adcp.testing`` to close gaps surfaced by the
salesagent v3.12 → 4.x migration:

- ``make_request_context(account=..., **overrides)`` — build a
  ``RequestContext`` for unit tests with stable defaults. The dataclass
  has 11 fields with factory defaults; this helper documents what tests
  should reach for so adopters don't have to guess which factory
  defaults are safe.
- ``build_asgi_app(platform, name=...)`` — build a Starlette ASGI app
  from a ``DecisioningPlatform`` without binding a port. Drops the F12
  webhook gate by default (``auto_emit_completion_webhooks=False``) so
  sales-platform tests construct without wiring webhook infra.

Both exposed at ``adcp.testing.{make_request_context, build_asgi_app}``.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add the four SalesPlatform-required stubs (get_media_buys,
  list_creative_formats, list_creatives, provide_performance_feedback)
  to the test fixture. Drops the 24-warning soft-warn cascade to 4.
- Rename test_build_asgi_app_threads_name → ..._accepts_name_kwarg
  to reflect what the test actually asserts (construction succeeds;
  wiring is framework-internal).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testing: ship adcp.testing.make_request_context + build_asgi_app helpers

1 participant