Skip to content

Add a real Django/DB-backed integration test tier for the endpoint trust boundary#164

Merged
wpak-ai merged 4 commits into
cppalliance:developfrom
whisper67265:feature/db-integration-test
Jul 8, 2026
Merged

Add a real Django/DB-backed integration test tier for the endpoint trust boundary#164
wpak-ai merged 4 commits into
cppalliance:developfrom
whisper67265:feature/db-integration-test

Conversation

@whisper67265

@whisper67265 whisper67265 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Close #160.

Summary by CodeRabbit

  • New Features
    • Added DB-backed PostgreSQL integration tests for ORM idempotency/slug behavior and the add-or-update API trust boundary.
    • Introduced a dedicated CI PostgreSQL job (reusable workflow) running pytest -m postgres.
  • Bug Fixes
    • Updated test selection so PostgreSQL tests run only when explicitly enabled.
    • Ensured DJANGO_SETTINGS_MODULE is honored when pre-set; improved transaction-related test isolation.
  • Documentation
    • Expanded README and contributing guides with the PostgreSQL test layout, what it verifies, and local Docker + the exact pytest command.
    • Updated CI documentation to reflect the new PostgreSQL runner.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e382794b-ff7b-40c8-96f4-0f7060db3a7c

📥 Commits

Reviewing files that changed from the base of the PR and between d3e8bc6 and 4855900.

📒 Files selected for processing (2)
  • .github/WORKFLOWS.md
  • README.md
✅ Files skipped from review due to trivial changes (2)
  • .github/WORKFLOWS.md
  • README.md

📝 Walkthrough

Walkthrough

This PR adds a postgres-marked Django integration tier, wires it into CI, and updates pytest configuration, shared test fixtures, endpoint and ORM integration tests, and developer documentation.

Changes

PostgreSQL Integration Test Tier

Layer / File(s) Summary
Pytest config and integration settings
pyproject.toml, tests/conftest.py, tests/django_integration_settings.py
Adds pytest-django, sets default Django test settings, excludes postgres from default runs, preserves external settings overrides, and defines the DB-backed integration settings module.
Shared postgres fixtures
tests/postgres/__init__.py, tests/postgres/conftest.py
Adds the postgres test package, collection filtering, cache and lock isolation, throttle overrides, authenticated integration user/client fixtures, and a mocked Celery delay helper.
Endpoint trust boundary tests
tests/postgres/test_endpoint_trust_boundary.py, tests/endpoint/test_views.py
Adds integration tests for rejecting adversarial payloads and accepting valid enqueue requests, plus a unit-test monkeypatch to avoid a real transaction.
ORM service integration tests
tests/postgres/test_services_orm.py
Adds integration tests for project slug generation, idempotency, language separation, post-create invocation, and rollback on failure.
CI wiring and docs
.github/workflows/ci-postgres.yml, .github/workflows/ci.yml, CONTRIBUTING.md, README.md, .github/WORKFLOWS.md
Adds the reusable PostgreSQL workflow, wires it into CI, and updates contributor and README guidance for the new test tier.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ci as .github/workflows/ci.yml
  participant workflow as .github/workflows/ci-postgres.yml
  participant postgres as postgres:16-alpine
  participant pytest as pytest -m postgres

  ci->>workflow: invoke postgres job
  workflow->>postgres: start database service
  workflow->>pytest: run integration tests with DB env vars
  pytest->>postgres: read/write test data
  postgres-->>pytest: query results
Loading

Possibly related PRs

Suggested reviewers: henry0816191, wpak-ai

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a Django/DB-backed integration test tier.
Linked Issues check ✅ Passed The new postgres tests, settings, CI workflow, and docs match the issue's integration-tier acceptance criteria.
Out of Scope Changes check ✅ Passed The changes appear focused on the PostgreSQL integration tier and supporting docs/config, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/django_integration_settings.py (1)

30-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant branching for INSTALLED_APPS append.

+= works identically for both list and tuple targets here (tuple concatenation vs. list extend), so the isinstance check adds complexity without behavioral difference.

♻️ Simplification
 if _ENDPOINT_APP_CONFIG not in INSTALLED_APPS:  # noqa: F405
-    if isinstance(INSTALLED_APPS, tuple):  # noqa: F405
-        INSTALLED_APPS = INSTALLED_APPS + (_ENDPOINT_APP_CONFIG,)  # noqa: F405
-    else:
-        INSTALLED_APPS += (_ENDPOINT_APP_CONFIG,)  # noqa: F405
+    INSTALLED_APPS += (_ENDPOINT_APP_CONFIG,)  # noqa: F405
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/django_integration_settings.py` around lines 30 - 34, The
INSTALLED_APPS update in the Django integration settings has redundant type
branching, since the append behavior is the same for both list and tuple
targets. Simplify the logic around _ENDPOINT_APP_CONFIG by removing the
isinstance(INSTALLED_APPS, tuple) conditional and using a single += path in the
INSTALLED_APPS block so the code remains equivalent but easier to read and
maintain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/django_integration_settings.py`:
- Around line 30-34: The INSTALLED_APPS update in the Django integration
settings has redundant type branching, since the append behavior is the same for
both list and tuple targets. Simplify the logic around _ENDPOINT_APP_CONFIG by
removing the isinstance(INSTALLED_APPS, tuple) conditional and using a single +=
path in the INSTALLED_APPS block so the code remains equivalent but easier to
read and maintain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24bb8ef1-ec0f-4868-bb48-72d423784f37

📥 Commits

Reviewing files that changed from the base of the PR and between bcbffc3 and 7503c8c.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • .github/workflows/ci-postgres.yml
  • .github/workflows/ci.yml
  • CONTRIBUTING.md
  • README.md
  • pyproject.toml
  • tests/conftest.py
  • tests/django_integration_settings.py
  • tests/endpoint/test_views.py
  • tests/postgres/__init__.py
  • tests/postgres/conftest.py
  • tests/postgres/test_endpoint_trust_boundary.py
  • tests/postgres/test_services_orm.py

@henry0816191 henry0816191 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add a row in .github/WORKFLOWS.md- Workflows table - lines 13–28 forci-postgres.ymlafterci-test.yml` (DB-backed integration tests, Python 3.12, PostgreSQL service container).

Comment thread README.md
@whisper67265 whisper67265 requested review from wpak-ai and removed request for AuraMindNest July 8, 2026 17:52
@wpak-ai wpak-ai merged commit 9d29d33 into cppalliance:develop Jul 8, 2026
13 checks passed
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.

Django/DB-backed integration test tier for the endpoint trust boundary

3 participants