Idempotent order creation
`create_order(client, payload, key)` creates an order idempotently.
Client: `post("/orders", json=payload, headers=headers)` → a response with
`status_code` and `json()`.
Rules:
- `201` — return the response body;
- `409` — return `{"duplicate": True}`, no retries;
- `5xx` — retry, at most three attempts in total;
- `4xx` (except 409) — `ApiError` immediately;
- every request must carry an `Idempotency-Key` header with the given key.
Write tests with a fake client: success, retry after a 500, 409, 400, and
exhausted attempts. Check both the responses and the headers.
The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.
Log in and askHint 1
What makes 409 different from 500 when it comes to retries? One status is a
result, the other is a transient failure.