test: add discount capability conformance module#62
Open
vishkaty wants to merge 1 commit into
Open
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) which the JSON schema cannot express, and that client-supplied discounts.applied[] (a response-only field, ucp_request: omit) does not change the priced total (DSC-027) so a client cannot inject a discount. Server-agnostic: relative assertions driven by codes in conformance_input.json, with honest skips when no code is configured, the business does not advertise dev.ucp.shopping.discount, or the server emits no allocations[].
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).