Practice ยท 1 of 1
Preserve the contract, restructure the code
Implement process_orders(orders, notifier, audit) per this EXACT contract (given as the refactored behavior):
- for each order: total <= 0 โ append {'id': id, 'status': 'skipped'} to audit, continue
- otherwise notifier.send(order['email'], 'order <id> confirmed'); success โ append 'sent'
- on notification failure โ append 'failed' to audit, then RE-RAISE the exception (batch aborts)
- return the audit list
The hidden probe verifies three different notifier behaviors (happy, one failure mid-batch, all-skipped) โ your implementation must match the contract exactly, in order.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Project: Refactor Without Behavior Change