Commit 675572a
committed
review: pin /api/search missing-q contract to 400 (#32)
CodeRabbit flagged that the permissive ``assert status_code in (200, 400)``
let either contract pass, so a drift between the two behaviours would go
unnoticed. The shipped implementation (api/search.py:74-75) returns
``400 with {"error": "No search query provided"}`` for missing or empty q.
Replaced the single permissive test with three concrete ones, each
asserting the same 400 + error-body contract:
- test_missing_q_returns_400 — GET /api/search (no q at all)
- test_empty_q_returns_400 — GET /api/search?q= (empty)
- test_whitespace_only_q_returns_400 — GET /api/search?q=%20%20%20
(api/search.py strips before checking)
191 pytest tests pass (was 189; +2 from the split).1 parent fb549ec commit 675572a
1 file changed
Lines changed: 18 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
0 commit comments