Skip to content

Add Pytest QA suite for all endpoints + known-gap regressions - #1

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784149989-pytest-suite
Open

devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784149989-pytest-suite

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Summary

Adds test_python_fastapi.py — a self-contained Pytest suite (40 tests) covering all 12 API endpoints (happy path, negative path, auth-required, wrong-credentials) plus targeted regression tests for the Critical/High QA gaps found earlier. No application code is changed — this PR only adds tests.

Result: 34 passed, 1 skipped, 5 xfailed (suite is green).

Known bugs are asserted at their correct expected behaviour and marked xfail so the suite stays green while documenting each defect. If a bug is later fixed, the test XPASSes (strict), signalling the marker should be removed. Gaps that need an infra change to test are skip placeholders.

Gap-specific tests:

  • IDOR — bob cannot modify/delete alice's post (these pass — ownership is checked). bob reading alice's post via GET /{id} and seeing it in GET / are xfail (no ownership check → confidentiality bug).
  • update_post 404 — PUT /api/posts/{missing} should return 404; currently returns 200 (xfail strict).
  • Invalid UUID — GET /api/posts/not-a-uuid should return 400; currently 500 (xfail strict).
  • POST validation — missing fields → 422 (passes); empty strings → 422 is xfail (schema has no min_length).
  • Login rate limit — skip placeholder asserting a future 429; needs a limiter (slowapi/Redis) to test.

Test harness notes:

# isolated DB derived from settings, created if absent
TEST_DATABASE_URL = <base>/<POSTGRES_DB>_test
# per-test TRUNCATE ... RESTART IDENTITY CASCADE for a clean slate
# get_db overridden via app.dependency_overrides
# SMTP patched out (register): app.routers.auth.Email -> fake no-op
# auth via Authorization: Bearer <access_token> from /login
# TestClient(app, raise_server_exceptions=False) so a buggy 500 is
#   returned as a response instead of bubbling up

Run:

pytest test_python_fastapi.py -v   # requires reachable Postgres (see .env / docker-compose.yml)

Link to Devin session: https://app.devin.ai/sessions/00a96a01db324b9583129cd1fd0e9ac4
Requested by: @tejasri757


Open in Devin Review

@tejasri757 tejasri757 self-assigned this Jul 15, 2026
@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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

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.

2 participants