Title: feat(testing): build_test_client(platform) — async context manager wrapping lifespan + httpx client · Issue #549 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: feat(testing): build_test_client(platform) — async context manager wrapping lifespan + httpx client · Issue #549 · adcontextprotocol/adcp-client-python
X Title: feat(testing): build_test_client(platform) — async context manager wrapping lifespan + httpx client · Issue #549 · adcontextprotocol/adcp-client-python
Description: Summary build_asgi_app(platform) (PR #535) gives adopters the ASGI app they need for in-process integration tests. But every test that uses it writes the same 4 lines of boilerplate to wire the lifespan + transport + httpx client: ```pyt...
Open Graph Description: Summary build_asgi_app(platform) (PR #535) gives adopters the ASGI app they need for in-process integration tests. But every test that uses it writes the same 4 lines of boilerplate to wire the lif...
X Description: Summary build_asgi_app(platform) (PR #535) gives adopters the ASGI app they need for in-process integration tests. But every test that uses it writes the same 4 lines of boilerplate to wire the lif...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/549
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(testing): build_test_client(platform) — async context manager wrapping lifespan + httpx client","articleBody":"## Summary\n\n`build_asgi_app(platform)` (PR #535) gives adopters the ASGI app they need for in-process integration tests. But every test that uses it writes the same 4 lines of boilerplate to wire the lifespan + transport + httpx client:\n\n\\`\\`\\`python\nfrom asgi_lifespan import LifespanManager\nimport httpx\nfrom adcp.testing import build_asgi_app\n\nasync def test_something():\n app = build_asgi_app(platform)\n async with LifespanManager(app):\n async with httpx.AsyncClient(\n transport=httpx.ASGITransport(app=app),\n base_url=\\\"http://test\\\",\n ) as client:\n resp = await client.post(\\\"/mcp\\\", json=...)\n # finally — the actual test\n\\`\\`\\`\n\nA `build_test_client(platform)` helper that bundles those three layers into one async context manager collapses adopter test files significantly:\n\n\\`\\`\\`python\nfrom adcp.testing import build_test_client\n\nasync def test_something():\n async with build_test_client(platform) as client:\n resp = await client.post(\\\"/mcp\\\", json=...)\n\\`\\`\\`\n\n## Proposed shape\n\n\\`\\`\\`python\n@asynccontextmanager\nasync def build_test_client(\n platform: DecisioningPlatform,\n *,\n base_url: str = \\\"http://test\\\",\n name: str | None = None,\n advertise_all: bool = False,\n auto_emit_completion_webhooks: bool = False,\n headers: Mapping[str, str] | None = None,\n **factory_kwargs: Any,\n) -> AsyncIterator[httpx.AsyncClient]:\n \\\"\\\"\\\"...\n Yields an httpx.AsyncClient wired against the platform's ASGI app\n via httpx.ASGITransport + LifespanManager. Closes both on exit.\n \\\"\\\"\\\"\n app = build_asgi_app(\n platform,\n name=name,\n advertise_all=advertise_all,\n auto_emit_completion_webhooks=auto_emit_completion_webhooks,\n **factory_kwargs,\n )\n async with LifespanManager(app):\n async with httpx.AsyncClient(\n transport=httpx.ASGITransport(app=app),\n base_url=base_url,\n headers=dict(headers) if headers else None,\n ) as client:\n yield client\n\\`\\`\\`\n\n~25 LOC of implementation; surface mirrors `build_asgi_app` so adopters who outgrow the convenience helper drop down to the lower layer with no API rewrite.\n\nThe `headers=` kwarg is the small extra value-add — adopters testing the auth path use `headers={\\\"x-adcp-auth\\\": \\\"tok_...\\\"}` once at the client level instead of per-request.\n\n## Migration impact\n\n`asgi_lifespan` and `httpx` are already test-only deps in adopters using `build_asgi_app`. No new install. The helper makes them transitive for anyone using `build_test_client` (move them from per-test to a single import in their conftest).\n\n## Test count this would simplify\n\nsalesagent's `core/tests/test_e2e_get_products.py` and the M2-roadmap storyboard tests collapse by ~half. Multiplying across the framework's own test suite, the savings compound.\n\n## Related\n\n- Round-1 ask #11 (carried in salesagent SDK_FEEDBACK round-2 #24) was specifically the `build_asgi_app(platform)` helper — that shipped in PR #535 and closed the carry. ✅\n- This issue captures one of three smaller follow-up gaps that are independent of the round-1 ask:\n - **(this issue)** `build_test_client` convenience — ~30 LOC, biggest UX win\n - Returning handler/executor/registry from `build_asgi_app` for tests that need to inspect framework state — would file separately if helpful\n - A2A test seam (today's `build_asgi_app` only mounts MCP) — would file separately as adopters start exercising A2A in tests\n\nHappy to PR this one if it'd help — small enough to be a 1-PR drive-by.\n\n🤖 Filed via Claude Code","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-04T02:33:07Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/549"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:09ae2dc6-f7ff-2d83-f784-7decbc728e42 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 99FE:3C21B:100D4CF:14A68EF:6B010265 |
| html-safe-nonce | bbe7ada735fe727b0c37bf6fef58de6d12188aebafe142c11867ac96e691d432 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUZFOjNDMjFCOjEwMEQ0Q0Y6MTRBNjhFRjo2QjAxMDI2NSIsInZpc2l0b3JfaWQiOiI4MTAwODUzNjU4MzQzNzY4Njc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c715181c2e9801098949314802f16756faa172fa72b37479e2fb5e6a8b3ae15d |
| hovercard-subject-tag | issue:4373701635 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/549/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f371b050ac1bfd5b06dfe801eb7a90634c9ffa8739e80410ef036e704e33415/adcontextprotocol/adcp-client-python/issues/549 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f371b050ac1bfd5b06dfe801eb7a90634c9ffa8739e80410ef036e704e33415/adcontextprotocol/adcp-client-python/issues/549 |
| og:image:alt | Summary build_asgi_app(platform) (PR #535) gives adopters the ASGI app they need for in-process integration tests. But every test that uses it writes the same 4 lines of boilerplate to wire the lif... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width