Skip to content

test: add runtime tests, integration tests, and CI with local MongoDB#1

Open
sis0k0 wants to merge 7 commits into
mainfrom
add-tests-and-ci
Open

test: add runtime tests, integration tests, and CI with local MongoDB#1
sis0k0 wants to merge 7 commits into
mainfrom
add-tests-and-ci

Conversation

@sis0k0
Copy link
Copy Markdown
Member

@sis0k0 sis0k0 commented May 22, 2026

Summary

Adds a complete testing and CI layer to this repository:

Runtime tests (tests/test_runtime.py)

Unit-level tests that import the app with in-process stubs and verify route registration, startup/shutdown lifecycle, and core handler logic — no network required.

Integration tests (tests/test_integration.py)

Pytest tests that connect to a real MongoDB instance and exercise the actual collection schema:

  • Full CRUD (insert / find / update / delete)
  • Filter and aggregation queries matching the app's DAL
  • Framework-level round-trips where available (Beanie ODM, Motor DAL, Starlette routes)

Tests skip automatically when MongoDB is not reachable.

CI (github/workflows/ci.yml)

  • Adds a mongo:latest service container with a mongosh health check (same pattern as mern-stack-example PR #51)
  • Sets MONGODB_URI: mongodb://admin:mongodb@localhost:27017/ for integration tests
  • Runs pytest tests/test_integration.py -v after the existing runtime test step

sis0k0 added 7 commits May 22, 2026 15:16
- tests/test_integration.py: per-repo pytest tests that connect to a real
  MongoDB instance and exercise the actual collection schema with CRUD operations
- tests/__init__.py: makes tests a package so pytest resolves modules correctly
- .github/workflows/ci.yml: adds mongo:latest service container (health-checked,
  port 27017) and a step that runs pytest tests/test_integration.py with
  MONGODB_URI pointing at the service container credentials

Pattern follows mongodb-developer/mern-stack-example PR #51.
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