feat(testing): make_request_context + build_asgi_app helpers#535
Merged
Conversation
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>
This was referenced May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #516.
Summary
Two adopter-facing test helpers in
adcp.testing:make_request_context(account=..., **overrides)— build aRequestContextfor unit tests with stable defaults. Default account isAccount(id="test-account"); pass a string shorthand for the common case (account="acme").build_asgi_app(platform, name=...)— build a Starlette ASGI app from aDecisioningPlatformwithout binding a port. Defaultauto_emit_completion_webhooks=Falseskips the F12 boot gate so sales platforms construct without wiring webhook infra.Why
Salesagent migration feedback #10 + #11:
Test plan
tests/test_testing_decisioning.py:make_request_contextstate/resolveuse framework v6.0 stubsbuild_asgi_appreturns an ASGI callable, default skips webhook gate, acceptsname=, threadsadvertise_all=, propagatesvalidate_platformerrorsruff,mypy, all pre-commit hooks pass🤖 Generated with Claude Code