Modules
app/main.py
The whole service. Owns: the FastAPI app, an in-memory
ORDERS dict (3 fixed orders), the order_total() pricing helper, and both HTTP endpoints. 29 lines, no other modules.tests/test_orders.py
5 tests using FastAPI's
TestClient: one order lookup (happy path + 404), one direct call to order_total() on a 2-line order, one on an empty order, and one account rollup. No test for a malformed line or an unknown account with mixed case.Endpoints
| Method | Path | Input | Output |
|---|---|---|---|
| GET | /orders/{order_id} |
Path param order_id (string, e.g. A-1001) |
200: order object + computed total. 404 {"detail":"order not found"} if unknown. |
| GET | /accounts/{account}/total |
Path param account (string, exact match, e.g. Account A) |
200: {account, orders: count, total} summed across that account's orders. 404 if no orders match. |
Test summary
4
passed
1
failed
test_get_order_ok
test_get_order_missing
test_total_two_lines assert 1256.0 == 1650.0
test_empty_order_total_is_zero
test_account_total
Ran with pytest -q against Python 3.14 / fastapi + httpx. Raw output: 1 failed, 4 passed, 2 warnings in 1.16s.