A small shop docs/screenshots-en/casebook_demo_en.yaml
Check prices, stock and receipts through the CLI and Python functions
Golden files: golden/casebook_demo_en/
<…> in the golden contents stands for a value replaced because it changes between runs
13 cases Passed 10 Skipped 1 Expected failure 1 Failed 1
| Category | Cases | Results |
|---|---|---|
| Pricing | 5 | Passed 5 |
| Stock | 3 | Passed 3 |
| Orders | 5 | Passed 2 Skipped 1 Expected failure 1 Failed 1 |
Cases to check
| Category | Subcategory | Item | Case | What is checked | Preconditions | Expected result | Result | Time |
|---|---|---|---|---|---|---|---|---|
Pricing Member and bulk discounts | Normal purchase | CLI | price_one store price apple 1 | No discount for a single item | — | Passed | 1 ms | |
Golden file (price_one.txt)# exit_code: 0 ----- stdout ----- apple x 1 = $15 (discount $0) | ||||||||
price_member store price apple 3 --member | Members get 10% off | — | Passed | 1 ms | ||||
Golden file (price_member.txt)# exit_code: 0 ----- stdout ----- apple x 3 = $41 (discount $4) | ||||||||
Function | quote_bulk store_en:quote | 5 or more items get $5 off | — | return = {"discount": 5, "total": 45} | Passed | 0 ms | ||
Invalid input | price_unknown_item store price grape 1 | An unknown item is an error | — | exit_code = 1 stderr contains "no such item" | Passed | 1 ms | ||
quote_zero store_en:quote | A quantity of 0 raises ValueError | — | raises = "ValueError" | Passed | 0 ms | |||
Stock | Normal | stock_available store stock apple | Shows the count when in stock | — | Passed | 1 ms | ||
Golden file (stock_available.txt)# exit_code: 0 ----- stdout ----- apple: 10 | ||||||||
stock_empty store stock banana | An item with no stock shows "out of stock" and exits with 3 | — | exit_code = 3 stdout contains "out of stock" | Passed | 1 ms | |||
Sold out | stock_sold_out store_en:stock | In the sold-out state, available is false | State: sold_out | return = {"available": false} | Passed | 0 ms | ||
Orders | Receipt | receipt_small store receipt apple=2 banana=1 | Orders under $300 pay $50 shipping | — | Passed | 1 ms | ||
Golden file (receipt_small.txt)# exit_code: 0 ----- stdout ----- apple x 2: $30 banana x 1: $10 Subtotal: $40 Shipping: $50 Total: $90 | ||||||||
receipt_free_shipping store receipt melon=2 apple=4 | Shipping is free at exactly $300 | — | Failed | 1 ms | ||||
Failure details[receipt_free_shipping] (line 81) Orders > Receipt Shipping is free at exactly $300 The output differs from the golden file. If the change is intended, update it with `--casebook-update`. --- golden/casebook_demo_en/receipt_free_shipping.txt (expected) +++ actual output @@ -3,5 +3,5 @@ melon x 2: $240 apple x 4: $60 Subtotal: $300 -Shipping: $0 -Total: $300 +Shipping: $50 +Total: $350 Golden file (receipt_free_shipping.txt)# exit_code: 0 ----- stdout ----- melon x 2: $240 apple x 4: $60 Subtotal: $300 Shipping: $0 Total: $300 | ||||||||
Reservation | reserve_short store_en:reserve | Not enough stock raises OutOfStock | stock: {"melon": 1} | raises = "OutOfStock" | Passed | 0 ms | ||
Points | points_round_down store_en:points | Amounts under $10 earn no points | — | return = 4 | Expected failure bug #12: rounds up | 0 ms | ||
Coupons | coupon_percent store_en:coupon | A 10% off coupon can be used | — | return = 90 | Skipped on hold until the spec is decided | 0 ms | ||