Added pytest configuration and first 4 unit tests
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m4s

This commit is contained in:
2025-05-27 17:37:05 -05:00
parent 4b1a7e9bea
commit cebbb9c1a8
14 changed files with 205 additions and 15 deletions

View File

@@ -1,12 +1,12 @@
import os
import boto3
from app.models import Base
from .constants import AWS_REGION
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from functools import lru_cache
@lru_cache(maxsize=1)
def get_db_credentials():
"""Fetch and cache DB credentials from environment or SSM Parameter Store"""
if os.getenv("MOCK_AUTH", "").lower() == "true":
@@ -25,14 +25,14 @@ def get_db_credentials():
except Exception as e:
raise RuntimeError(f"Failed to fetch DB credentials from SSM: {str(e)}")
# Initialize engine and session maker
engine = create_engine(get_db_credentials())
# Create all tables
from app.models import Base
Base.metadata.create_all(bind=engine)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def init_db():
"""Initialize database by creating all tables"""
Base.metadata.create_all(bind=engine)
def get_db():
"""Dependency for getting database session"""
db = SessionLocal()