test: added test cases for points.py and task.py
Bug Report Template
Title (semantic)
Format: fix(scope): short description
Example: fix(auth): resolve token validation error
1. test_task.py
Title (semantic)
fix(task-schemas): resolve validation, defaults, and serialization issues
Description
This merge request fixes multiple issues in task-related Pydantic schemas (app/schemas/task.py) identified through comprehensive testing.
The fixes address:
- Missing required field validation not raising
ValidationError - Incorrect handling of optional defaults (e.g.,
days_old,severity,format) - Type coercion inconsistencies (e.g., improper int → bool handling)
- Edge case failures (negative values, empty inputs, large numbers)
- Incorrect or incomplete
model_dump()serialization - Mutable default argument issues (shared state across instances)
Comprehensive tests were added in test_task.py to ensure schema correctness, robustness, and isolation.
Checklist
-
The bug has been reproduced and confirmed. -
A clear and concise fix has been implemented. -
New tests have been added to prevent regressions. -
Existing tests are passing.
2. test_points.py
Title (semantic)
fix(points-schemas): correct type coercion, nested validation, and date handling
Description
This merge request fixes issues in gamification-related schemas (app/schemas/points.py) uncovered during detailed validation testing.
The fixes include:
- Incorrect numeric coercion (int → float, int → bool)
- Improper date/datetime parsing and invalid string handling
- Nested schema validation errors in
PointsStatsResponseandCategoryLeaderboardResponse - Handling of optional fields with
Nonedefaults (e.g.,streak_expires_at,current_user_rank) - Edge case handling (zero/negative values, empty lists)
- Serialization issues with nested structures using
model_dump() - Type strictness enforcement for invalid inputs and incorrect nested types
New tests in test_points.py ensure accurate validation, serialization, and schema integrity.
Checklist
-
The bug has been reproduced and confirmed. -
A clear and concise fix has been implemented. -
New tests have been added to prevent regressions. -
Existing tests are passing.
Related Issue(s)
Closes #112 (closed)