feat: add MongoDB database as a part of the CLI#89
Merged
pythonhubdev merged 3 commits intomainfrom Sep 28, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes MongoDB test failures in generated FastAPI projects by making all test-related templates conditional based on the database_type parameter. Previously, test files were hardcoded for SQLAlchemy but failed when MongoDB was selected as the database type.
- Made all test templates conditionally render based on
database_type(SQLAlchemy vs MongoDB) - Added MongoDB-specific test configurations and fixtures
- Enhanced CLI testing script to include MongoDB test scenarios
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test_cli.sh | Added MongoDB test configurations and database_type parameter support |
| templates/fastapi_template/.../test_config.py.jinja | Added conditional MongoDB database settings test |
| templates/fastapi_template/.../test_health.py.jinja | Added MongoDB-specific health endpoint test with proper fixture |
| templates/fastapi_template/.../conftest.py.jinja | Added MongoDB client fixture and conditional SQLAlchemy imports |
| templates/fastapi_template/.../base.py.jinja | Added MongoDB-specific configuration settings |
| templates/fastapi_template/.../database.py.jinja | Added complete MongoDB connection manager using Beanie ODM |
| templates/fastapi_template/.../init.py.jinja | Added conditional imports for MongoDB vs SQLAlchemy |
| templates/fastapi_template/.../lifespan.py.jinja | Added MongoDB connection lifecycle management in FastAPI lifespan |
| templates/fastapi_template/.../pyproject.toml.jinja | Added MongoDB-specific dependencies (beanie, motor, pymongo) |
| templates/fastapi_template/.../README.md.jinja | Added conditional documentation for MongoDB vs SQLAlchemy features |
| templates/fastapi_template/.../.env.jinja | Added MongoDB environment variable configuration |
| src/scaffoldr/core/utils/helper.py | Added database_type selection helper method |
| src/scaffoldr/core/constants/const.py | Added DatabaseTypes enum for sqlalchemy and mongodb |
| src/scaffoldr/core/constants/init.py | Exported DatabaseTypes enum |
| src/scaffoldr/cli/generate.py | Added database_type parameter to template context |
| README.md | Updated documentation to mention MongoDB support alongside SQLAlchemy |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
templates/fastapi_template/{{ project_name }}/tests/test_health.py.jinja
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixed MongoDB test failures in generated FastAPI projects. The test files were hardcoded for SQLAlchemy but failed when MongoDB was selected as the database type. Made all test-related templates conditional based on
database_typeto support both SQLAlchemy and MongoDB configurations.Type of Change
Scope / Affected Areas
Breaking Changes
Public API Impact (Python SDK)
Testing & Verification
Documentation
Environment / Config Changes
Checklist