Skip to content

feat: add MongoDB database as a part of the CLI#89

Merged
pythonhubdev merged 3 commits intomainfrom
feat/mongo
Sep 28, 2025
Merged

feat: add MongoDB database as a part of the CLI#89
pythonhubdev merged 3 commits intomainfrom
feat/mongo

Conversation

@pythonhubdev
Copy link
Copy Markdown
Owner

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_type to support both SQLAlchemy and MongoDB configurations.

Type of Change

  • Bug fix

Scope / Affected Areas

  • Developer tooling

Breaking Changes

  • No

Public API Impact (Python SDK)

  • New modules/classes/functions:
  • Changed/removed APIs:
  • Deprecations (timeline and migration path):

Testing & Verification

  • Commands run locally:
    • task test (pytest)
    • task lint (ruff/pyright/mypy)
    • pre-commit run --all-files (optional)
  • Added/updated tests: [ ] unit [ ] integration
  • Key scenarios and edge cases:
    • Generated FastAPI projects with MongoDB database type now have working tests
    • SQLAlchemy projects continue to work as before
    • Both database types use appropriate connection patterns and fixtures

Documentation

  • Notes:
    • MongoDB support in scaffoldr now includes proper test configuration

Environment / Config Changes

  • New/changed env vars:
  • Defaults and validation:
  • Backwards compatible: [yes]

Checklist

  • Code formatted and linted (ruff format/check)
  • Type checks pass (pyright, mypy)
  • No secrets/keys committed

@pythonhubdev pythonhubdev self-assigned this Sep 28, 2025
@pythonhubdev pythonhubdev added the enhancement New feature or request label Sep 28, 2025
@pythonhubdev pythonhubdev changed the title feat/mongo feat: add MongoDB database as a part of the CLI Sep 28, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@pythonhubdev pythonhubdev merged commit 0769d3e into main Sep 28, 2025
4 checks passed
@pythonhubdev pythonhubdev deleted the feat/mongo branch September 28, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants