Commit d8748b4
committed
test: Add tests for /api/user/feed endpoint
1. Integration of comprehensive functional tests (`TestUserPromoFeed`) that verify core endpoint behaviors:
- Accurate user-specific promo targeting based on age and country.
- Correct dynamic calculation of promo 'active' status (considering dates, usage counts, and unique code availability).
- Effective filtering via `active` (boolean) and `category` (case-insensitive) query parameters.
- Proper pagination functionality using `limit` and `offset`, including `X-Total-Count` header validation.
- Verification of response data structure, ensuring exclusion of sensitive promo code values.
- Correct reflection of promo data updates (e.g., a promo becoming inactive after an edit) in the feed.
2. Addition of new focused validation tests (`TestUserPromoFeed`) using parameterized inputs to cover edge cases and invalid requests:
- Authentication checks, specifically ensuring `401 Unauthorized` for requests lacking a token.
- Rigorous validation of query parameters (`limit`, `offset`, `category`, `active`):
- Invalid data types and formats (e.g., non-numeric for `limit`/`offset`, non-boolean for `active`).
- Values outside defined constraints (e.g., negative `limit`/`offset`, category string length violations).
- Empty string inputs for parameters that require specific formats.
- Rejection of requests containing unexpected or unsupported query parameters, returning a `400 Bad Request`.1 parent bacab51 commit d8748b4
File tree
5 files changed
+848
-4
lines changed- promo_code/user
- tests/user
- operations
- validations
5 files changed
+848
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
300 | 313 | | |
301 | 314 | | |
302 | 315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
41 | 66 | | |
42 | 67 | | |
43 | 68 | | |
| |||
54 | 79 | | |
55 | 80 | | |
56 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
0 commit comments