Skip to content

Template Testing and Validation #17

@lbedner

Description

@lbedner

Goal

Comprehensive testing of database component template generation.

Implementation

  • Add database-specific template tests
  • Test both with and without database component
  • Validate generated projects pass all quality checks
  • Test database functionality in generated projects

Files Modified

  • tests/cli/test_cli_init.py — Add test cases for database component
  • Makefile — Add targets for database component testing

Testing Coverage

  • Database component selection and validation
  • Generated project structure with database
  • Database configuration and connection
  • Health check integration
  • Import validation

Success Criteria

  • All template tests pass with database component
  • Generated projects with database component pass make check
  • Database health checks work in generated projects
  • No broken imports or missing dependencies

Component Specification

"database": ComponentSpec(
    name="database",
    type=ComponentType.INFRASTRUCTURE,
    description="SQLite database with SQLModel ORM",
    requires=[],  # Standalone component
    recommends=[],
    conflicts=[],
    docker_services=[],  # No Docker services needed for SQLite
    pyproject_deps=["sqlmodel>=0.0.14", "sqlalchemy>=2.0.0", "aiosqlite>=0.19.0"],
    template_files=["app/core/db.py"],
)

Testing Strategy

Per Ticket:

  1. Unit Tests: Test individual functions and components
  2. CLI Tests: Test command-line integration
  3. Template Tests: Test generated project structure and functionality
  4. Integration Tests: Test database connectivity and health checks
  5. Quality Checks: Ensure all generated code passes linting and type checking

Overall Validation:

  • make test passes for Aegis Stack CLI
  • make test-template with database component passes
  • Generated projects with database component pass all quality checks
  • Database functionality works correctly in generated projects

Success Metrics

  1. CLI Integration: aegis init test-db --components db creates working project
  2. Database Functionality: Generated app/core/db.py provides working session management
  3. Health Monitoring: Database health checks integrate with existing system
  4. Code Quality: All generated code passes linting, type checking, and tests
  5. Documentation: Component documentation updated with database information

Risk Mitigation

  • SQLite File Location: Use relative path data/app.db that works in containers
  • Foreign Key Support: Ensure foreign key pragma set correctly for SQLite
  • Session Management: Proper exception handling and transaction rollback
  • Testing Isolation: Each ticket fully tested before proceeding to next

Future Considerations

  • PostgreSQL Support: Add as separate component or engine configuration option
  • Alembic Migrations: Add database migration support
  • Model Organization: Move from app/core/db.py to app/models/ structure
  • Backend Integration: Add database dependency injection to FastAPI routes
  • Scheduler Integration: Add database session access to scheduled tasks

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions