Skip to content

test(shopping): verify totals by the spec's formula, skip without the simulate-shipping hook - #139

Open
segiodongo wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
segiodongo:upstream/u3-fulfillment-totals-and-sim-skip
Open

segiodongo wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
segiodongo:upstream/u3-fulfillment-totals-and-sim-skip

Conversation

@segiodongo

Copy link
Copy Markdown
Collaborator

Description

Fixes two test assumptions that caused false failures against spec-compliant servers outside the bundled Flower Shop sample:

  • Verify fulfillment totals with the specification's formula (test_fulfillment_flow): Previously, test_fulfillment_flow asserted total == item_price + option_cost, failing against any server that includes tax or fee entries on the checkout. It now verifies that the fulfillment total entries sum to the selected option's cost and checks the overall breakdown via assert_totals_consistent (sum(entries where type != "total") == total, per checkout/index.md "Verification").
  • Skip simulation_url_security_test when /testing/simulate-shipping/{id} is absent: POST /testing/simulate-shipping/{order_id} is a sample-server test hook rather than a UCP specification endpoint, so servers without it previously failed all three SecurityTest methods. Matching test_update_event_is_full_order_entity in webhook_structure_test.py, SecurityTest now probes the hook with the configured secret when needed and skips on 404/405 (no simulation hook) or 403 (mismatched --simulation_secret), while still treating an unauthenticated 404 as a valid refusal when the probe confirms the hook exists.
  • Unit tests: Adds tests/fulfillment_and_simulation_test.py covering tax-bearing checkouts and simulation-hook skip/refusal paths, and wires uv run pytest tests into CI.

Verification

  • uv run pytest tests: 6 passed
  • uv run ucp-conformance --suite=all against the Flower Shop sample server: 83 executed, 81 passed, 2 skipped, 0 failures, 0 errors

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Nov 18, 2026
… simulate-shipping hook

Check in test_fulfillment_flow that fulfillment entries sum to the selected option's cost and that overall totals satisfy assert_totals_consistent instead of assuming price + shipping without tax or fees. Probe /testing/simulate-shipping/{order_id} in SecurityTest so servers without the sample-server hook skip on 404/405 and mismatched --simulation_secret skips on 403.
@segiodongo
segiodongo force-pushed the upstream/u3-fulfillment-totals-and-sim-skip branch from e7cdc3b to 3aa6ddd Compare November 18, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-triage Signal that the PR is ready for human triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants