Practice ยท 2 of 2
The repository speaks domain, not rows
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.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Data Service Mini-Project