Write a `payments.py` (or `payments.ts`) module that handles: coupon validation, price calculation (base price + tax + discount), order creation, and refund logic. Write unit tests for every function using proper AAA, fakes instead of mocks wherever possible, and boundary value tests for all validation rules. Achieve ≥80% mutation score (mutmut/Stryker). Write an integration test for the `create_order` function using an in-memory database. Document AI-assisted tests in the README (which tests were AI-generated, which were human-written).
validate_coupon function — it has clear rules (expired, wrong plan, already used) that generate good test cases.mutmut run --paths-to-mutate payments.py after your tests pass. Survival of arithmetic mutants (+ → -, > → >=) means you're missing boundary tests.better-sqlite3 (JS) or sqlite3 (Python) for integration tests — no Docker needed, spins up in milliseconds.$ pytest tests/ --cov=payments --cov-report=term-missing
========================= test session starts =========================
tests/unit/test_coupon.py ....... 7 passed
tests/unit/test_pricing.py ........ 8 passed
tests/unit/test_order.py ...... 6 passed
tests/integration/test_order_db.py ... 3 passed
========================= 24 passed in 0.42s =========================
Name Stmts Miss Cover
--------------------------------------
payments.py 78 2 97%
$ mutmut results
🎉 24 out of 27 mutants killed (89% mutation score)
calculate_price(base, tax_pct, discount_pct), generate random valid inputs and assert that the result is always between 0 and base * (1 + tax_pct/100). What invariants can you assert?@pytest.mark.parametrize or test.each.