test: add discount capability conformance module#62
Merged
damaz91 merged 3 commits intoJul 24, 2026
Merged
Conversation
Complements business_logic_test.py by covering discount MUSTs the suite does not assert: case-insensitive code matching (DSC-005), the negative sign of a discount's totals[] entry (DSC-021; total.json exclusiveMaximum: 0), codes[] replacement (DSC-003) and removal (DSC-004), the cross-field invariant that an applied discount's allocations[] sum to its amount (DSC-022), and that client-supplied discounts.applied[] (response-only, ucp_request: omit) does not change the priced total (DSC-027). Uses the fixture_ctx discount-code helpers (get_test_discount_code / get_test_discount_code_2) and the valid_discount_code / valid_discount_code_2 conformance_input keys, consistent with business_logic_test after Universal-Commerce-Protocol#63. Skips honestly when the business does not advertise the capability or emits no allocations[].
vishkaty
force-pushed
the
feat/discount-conformance
branch
from
July 24, 2026 04:19
a81a893 to
fa5c649
Compare
TAG=agy CONV=ba2601d2-c9f2-44dd-b597-7f95df69075a
TAG=agy CONV=ba2601d2-c9f2-44dd-b597-7f95df69075a
damaz91
approved these changes
Jul 24, 2026
ptiper
approved these changes
Jul 24, 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.
What
Adds
discount_test.py, a conformance module for the discount capability(
dev.ucp.shopping.discount). It complements the discount coverage already inbusiness_logic_test.py(discount flow, multiple-code accept/reject,fixed-amount) by asserting discount MUSTs from
discount.mdthat the suite doesnot yet check:
test_code_matches_case_insensitivelytest_discount_total_is_negativetotals[]entry is negative (total.jsonexclusiveMaximum: 0)test_codes_replace_previous_setcodes[]set replaces the previous onetest_empty_codes_removes_discountcodes[]removes all discountstest_allocations_sum_to_applied_amountallocations[]sum to itsamount(a cross-field invariant the JSON schema cannot express)test_client_applied_does_not_change_pricediscounts.applied[](response-only,ucp_request: omit) does not change the priced totalWhy
These are the discount behaviours most likely to differ silently between
implementations — case-folding, the sign convention on
totals[], code-setreplacement vs. accumulation, and the allocation/amount reconciliation. They are
currently unverified at the conformance level, so a merchant can regress them
and still pass. The last test also locks in that discounts are priced
server-side: a client cannot inject a cheaper order via the response-only
applied[]field.Design
Consistent with the
conformance_input-driven approach in #58: assertions arerelative (a discount reduced the total; the applied code is echoed; the
discount total is negative; an empty set clears it; allocations reconcile)
rather than tied to a specific discount value, so any conformant business passes
regardless of the discount amounts it offers. Codes are read from
conformance_input.jsonundertest_fixtures(
valid_discount_code/second_discount_code). The module skips honestly whenno code is configured, the business does not advertise the capability, or the
server emits no
allocations[].Verification
pre-commit run --all-filesclean (ruff, ruff-format, prettier, codespell).