Skip to content

Add comprehensive edge-case tests for AI Parenting feature#2

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1780008514-ai-parenting-edge-case-tests
Open

Add comprehensive edge-case tests for AI Parenting feature#2
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1780008514-ai-parenting-edge-case-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Adds 185 edge-case tests across 8 test files for the AI Parenting Guide backend (apps/ai-parenting-guide/backend/tests/). Covers:

Test file Tests Focus
test_gemini_ai_service.py 38 Boundary values, empty inputs, cache hit/miss, model errors, concurrent requests, helper methods
test_auth_service.py 23 Password hashing (empty, unicode, bcrypt boundary), JWT creation/decoding, token blacklisting, auth flows
test_rate_limiter.py 21 Role-based limits, boundary values, burst detection, Redis fail-open, concurrent users, admin reset
test_api_endpoints.py 24 Input validation (min/max), empty bodies, service error 500s, health checks, community CRUD
test_schemas.py 35 Pydantic validation boundaries, required fields, enum validation, points range, duration constraints
test_middleware.py 8 Security headers, endpoint type detection, public endpoint bypass, request logging
test_models.py 16 User/Discussion/Comment creation, unique constraints, cascade deletes, default values
test_file_upload.py 10 Upload stub, multimodal analysis (image/text/mixed), large content, concurrent analysis

Also includes conftest.py with compatibility patches for existing code issues discovered during testing:

  • Pydantic v2 regexpattern migration needed in schemas/learning.py
  • Base import mismatch in models/learning.py
  • AuthService.require_role async factory issue
  • UserSession.token_jti vs UserSession.token mismatch
  • Missing schema stubs (UserUpdate, etc.)

All 185 tests pass locally: pytest tests/ -v

Review & Testing Checklist for Human

  • Run cd apps/ai-parenting-guide/backend && pip install -r requirements.txt && pip install pytest pytest-asyncio httpx && pytest tests/ -v to verify all tests pass
  • Review conftest.py compatibility patches — these workaround existing code bugs that should be addressed separately
  • Verify test coverage is adequate for your risk tolerance (run with --cov=app for coverage report)

Notes

  • The existing codebase has several compatibility issues (pydantic v2 migration incomplete, model/service mismatches) — these are noted in the conftest but NOT fixed in this PR to keep scope focused on tests only.
  • bcrypt 4.0.1 is needed (bcrypt 5.x rejects passwords in passlib's internal detection code)

Link to Devin session: https://app.devin.ai/sessions/7af5954fecba4ab78cb8d603a076ab43
Requested by: @sakomws

Test coverage across 8 test files with 185 tests:

- test_gemini_ai_service.py: Boundary values, empty inputs, cache hits/misses,
  model error propagation, concurrent requests, helper methods
- test_auth_service.py: Password hashing (empty, unicode, bcrypt boundary),
  JWT token creation/decoding, blacklisted tokens, user lookup, auth flows
- test_rate_limiter.py: Role-based limits, boundary values, burst detection,
  Redis failure (fail-open), concurrent users, admin reset operations
- test_api_endpoints.py: Input validation (min/max lengths), empty bodies,
  service error 500s, health check, community thread CRUD
- test_schemas.py: Pydantic validation (boundary values, required fields,
  enum validation, points range, duration constraints)
- test_middleware.py: Security headers presence, endpoint type detection,
  public endpoint bypass, request logging
- test_models.py: User/Discussion/Comment creation, unique constraints,
  cascade deletes, nullable fields, default values
- test_file_upload.py: Upload stub, multimodal analysis (image/text/mixed),
  large content, concurrent analysis requests, service errors

Also includes conftest.py with compatibility patches for existing code issues
(pydantic v2 regex->pattern, Base import, AuthService.require_role).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant