Skip to content

test(server): refactor spec_compat tests to use public API (#653)#657

Merged
bokelley merged 1 commit into
mainfrom
claude/issue-653-spec-compat-test-refactor
May 11, 2026
Merged

test(server): refactor spec_compat tests to use public API (#653)#657
bokelley merged 1 commit into
mainfrom
claude/issue-653-spec-compat-test-refactor

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Closes #653.

The tests in tests/test_spec_compat_hooks.py (added in #648) reached into private helpers (_hook_get_products, _make_sync_creatives_hook, _coerce_asset, _infer_asset_type) and asserted on internal shapes. Per CLAUDE.md the testing contract is to call the public API and validate against the generated Pydantic schemas — the previous tests passed but would not catch a regression where the hook produced dicts that failed at the dispatcher boundary.

What changed

  • Public-surface only. All 40 tests now exercise spec_compat_hooks() and the returned dict — no private imports.
  • Schema-validation proofs. Four model_validate() tests prove the hook output is actually 4.4-spec-valid:
    • test_get_products_hook_output_passes_pydantic_validation
    • test_sync_creatives_hook_output_passes_pydantic_validation_format_id_wrap
    • test_sync_creatives_hook_output_passes_pydantic_validation_inference_path
    • test_sync_creatives_hook_output_passes_pydantic_validation_demotion_path
  • Expanded integration coverage. create_tool_caller integration suite went from one buying_mode smoke test to four end-to-end paths (get_products default, sync_creatives format_id wrap, asset_type inference, image→url demotion).
  • Warn on unknown exclude= names. spec_compat_hooks(exclude={"sync_creative"}) (typo) now emits a UserWarning instead of silently leaving the hook active.

Test plan

  • pytest tests/test_spec_compat_hooks.py — 40 passed
  • ruff check src/adcp/server/spec_compat.py tests/test_spec_compat_hooks.py
  • mypy src/adcp/server/spec_compat.py
  • No private imports from adcp.server.spec_compat
  • Each new model_validate() test calls SyncCreativesRequest.model_validate() / GetProductsRequest.model_validate() on the hook's output

🤖 Generated with Claude Code

Closes #653. The previous tests in tests/test_spec_compat_hooks.py
reached into private helpers (_hook_get_products, _make_sync_creatives_hook,
_coerce_asset, _infer_asset_type) and asserted on internal shapes, which
hid a class of bugs the public surface would expose.

Changes:

- All tests now exercise spec_compat_hooks() and the returned dict only.
  No private imports.
- Add four model_validate() proofs that hook output is actually 4.4-valid:
  one for get_products (buying_mode default), three for sync_creatives
  (format_id wrap, asset_type inference, image→url demotion). Failure
  here means the hook is producing dicts that pass our internal asserts
  but fail at the dispatcher boundary.
- Expand the create_tool_caller integration suite from one buying_mode
  smoke test to four end-to-end paths: get_products default, sync_creatives
  format_id wrap, asset_type inference, image→url demotion.
- spec_compat_hooks(exclude={...}) now emits a UserWarning for unknown
  hook names (typos like "sync_creative" used to silently leave the hook
  active). Document the behaviour in the factory's exclude= section.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit fcfee67 into main May 11, 2026
16 checks passed
@bokelley bokelley deleted the claude/issue-653-spec-compat-test-refactor branch May 11, 2026 07:40
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.

test(server): refactor spec_compat_hooks tests to use public API

1 participant