Repository navigation
Conversation
damaz91
left a comment
There was a problem hiding this comment.
LGTM — nice, well-isolated coverage of the normative dev.ucp.shopping.cart requirements, @vishkaty!
All four tests map directly to the Cart and Discount specifications:
test_conversion_uses_cart_contents_over_payload: Cartline_items(quantity=2) taking precedence over conflicting checkout payload items (quantity=9) duringcart_idconversion (_item_bag).test_second_conversion_returns_the_existing_checkout: Idempotent cart-to-checkout conversion returning the existingincompletecheckout session ID.test_cancel_returns_the_cart_state_before_deletion:POST /carts/{id}/cancelreturning200/201with the pre-deletion cartidand_item_bag(while appropriately leaving theSHOULDpost-cancelnot_foundcheck out of mandatory assertions).test_cart_discount_codes_carry_forward_to_checkout: Discount code fromself.fixture_ctx.get_test_discount_code()carrying forward to the converted checkout (_discount_is_visible) when_discount_extends_cart()is true.
4bc872a to
8a1edf8
Compare
|
Rebased onto main at #120 replaced the workflow loop over Run the way the workflow runs it, against the sample server booted from samples main The Note on #107 above is superseded. #107 is closed and was replaced by #120, which has merged, |
8a1edf8 to
22af7dc
Compare
|
Rebased onto main at The test content is unchanged. The file is now Measured on this head against the sample server from samples main: 4 passed. Without the |
Four cases over cart conversion: conversion uses cart contents over the payload, a second conversion returns the existing checkout, cancel returns the cart state before deletion, and cart discount codes carry forward. Placed as `shopping/cart/cart_test.py` in a new `shopping/cart/` package, following the layout Universal-Commerce-Protocol#121 landed, and registered as `shopping.cart.cart_test`. What makes the module execute: without the registry entry `--suite=all` resolves 83 cases and selects none of these four, and with it 87. Rebased onto main past Universal-Commerce-Protocol#122. The only conflict was the registry list, where Universal-Commerce-Protocol#112 and Universal-Commerce-Protocol#122 had each added an entry. The cart entry sits at the head of the shopping list, which keeps that list grouped by subpackage in alphabetical order. Obligations are cited by section name, in the module docstring and at each case, rather than by line number. The line numbers the module carried were correct when it was written and had since drifted, one of them onto an unrelated paragraph, which is the hazard of citing a moving document by line. Two cases were judging a conformant business wrongly, and both are corrected here. The discount case used the presence of the code in the response as its evidence that the code had applied, but a business may return a code it received without applying it, as the reference does for an unknown code. With a configured code that does not apply at the business under test, the case therefore ran with nothing applied, and it failed a business that carried its applied codes forward and dropped the unapplied one with a `discount_code_invalid` warning, which discount.md allows. Application now needs an applied entry naming the code or a discount in totals, so such a code skips the case instead. Carry-forward is still satisfied by naming the code, and a discount standing in for it must now be at least as large as the one on the cart, so an unrelated discount no longer counts. The contents comparison took line items as a bag of id and quantity pairs, which failed a business expressing two units as two single-unit lines. It now sums quantity per item id and leaves out lines naming a parent, which still catches a business that takes its quantities from the request payload. Verified against the flower shop reference: the module alone gives 4 passed and 0 skipped; --suite=all gives 87 executed, 85 passed, 2 skipped, 0 failures; the pinned pre-commit, ruff, ruff format and cspell are clean. Nine servers each breaking one obligation redden their own case and nothing else, and the two corrections above are each held by a server that fails the old code and passes the new one.
22af7dc to
35e5556
Compare
|
Rebased onto main past #122. The only conflict was the registry list in Two other things came out of re-running the cases, both corrected here. The obligations were cited by line number. Those numbers were right when the The discount case used the presence of the code in the response as its The contents comparison took line items as a bag of id and quantity pairs, Verification on the rebased branch, against the flower shop reference:
|
|
Hi, thanks for putting this together. I tested two related cart-to-checkout cases against the Python sample at 52319dff that might be useful alongside the sequential conversion test:
Would checks for these cases fit the conformance suite? The sample continued after my synthetic agent profile failed to resolve, so the results need confirmation with a reachable profile. |
What
Adds
cart_test.py, covering the cart capability. The suite has no cartcoverage today: the string
dev.ucp.shopping.cartappears nowhere in therepository, and the only occurrence of the word is one English usage in a
fulfillment_structure_test.pydocstring. The reference server implements andadvertises the capability, so it is testable now.
Four assertions, each traced to a MUST, each verified on the wire:
cart.md:66cart.md:72-74cart.md:185discount.md:143Line references are to
release/2026-04-08, the version this suite targets.Kept server agnostic
Issues #101 to #103 point out that assertions elsewhere encode the reference
merchant rather than the specification, so this module avoids that by
construction:
server assigned identifiers
fixture_ctx, so nothing is hardcodedbusiness may use: the echoed code, an
appliedentry, or a negativediscounttotal, becausediscount.md:145lets a business drop a code thatis no longer valid at checkout time
The module gates on the capability being advertised and skips honestly
otherwise, since cart is deliberately not in
conformance_input.jsonrequired_capabilities. The discount assertion additionally skips unless thediscount capability declares it extends cart, which
discount.md:59permits itnot to.
Deliberately not asserted
Two nearby rules look assertable and are not, which is worth stating so the
omission does not read as an oversight:
cart.md:176("full replacement") binds the platform, not the business.The business side sentence carries no RFC 2119 keyword, so this suite cannot
hold a merchant to it.
cart.md:186(subsequent operations returnnot_found) is a SHOULD, sothe status after cancel is not asserted.
Testing
Against the reference server at the pinned
ucp-sdk==0.4.6, run exactly as theworkflow runs it: 4 passed.
Each assertion was then shown to fail on its own, by mutating the reference
server and re-running. Each mutation failed exactly one assertion and nothing
else:
Removing cart from the advertised profile makes all four skip rather than fail.
ruff checkandruff format --checkare clean.Whole suite run for a control: unchanged.
order_test.pyfails two tests bothbefore and after this change, on a pristine tree with a fresh database and this
file absent, so those are pre-existing and unrelated.
Note on #107
This lands as a top level
cart_test.py, which is what the current workflowpicks up (
for test_file in *_test.py). #107 relocates every module intoshopping/<capability>/. Its diff has no cart content, so there is no overlap,but if it merges first this file should move to
shopping/cart/cart_test.py.Happy to rebase it that way, or to hold this until #107 lands, whichever suits.