Skip to main content

Practice · 2 of 2

The repository speaks domain, not rows

CHALLENGE
Difficulty: advanced+25 XP

Implement OrderRepository(rows=None) with OrderNotFound: - get(order_id) returns a COPY of the matching row, or raises OrderNotFound - add(order_id, total, customer_id) appends a row; duplicate ids raise ValueError('duplicate order id') - for_customer(customer_id) returns copies of matching rows The contract under test: missing data is a loud domain error, duplicates are integrity violations, and callers can never mutate internal state.

Back to lesson: Practice: Data Service Mini-Project