mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Fix tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Settings configuration"""
|
||||
import os
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
class Settings(BaseSettings):
|
||||
@@ -8,7 +9,8 @@ class Settings(BaseSettings):
|
||||
API_V1_STR: str = "/api"
|
||||
|
||||
# Database
|
||||
DATABASE_URL: str = "postgresql://postgres:postgres123@db:5432/support_db"
|
||||
TESTING: bool = os.getenv("TESTING", "False") == "True"
|
||||
DATABASE_URL: str = "sqlite:///./test.db" if TESTING else "postgresql://postgres:postgres123@postgres:5432/support_db"
|
||||
|
||||
# JWT
|
||||
SECRET_KEY: str = "your-secret-key"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from .core.config import settings
|
||||
from .db.base import Base
|
||||
|
||||
# Для создания таблиц импортируем модели
|
||||
from .models.employee import Employee # noqa
|
||||
@@ -11,7 +10,13 @@ from .models.token import Token # noqa
|
||||
|
||||
SQLALCHEMY_DATABASE_URL = settings.DATABASE_URL
|
||||
|
||||
engine = create_engine(SQLALCHEMY_DATABASE_URL)
|
||||
# Для SQLite нужны специальные параметры подключения
|
||||
connect_args = {"check_same_thread": False} if settings.DATABASE_URL.startswith("sqlite") else {}
|
||||
|
||||
engine = create_engine(
|
||||
SQLALCHEMY_DATABASE_URL,
|
||||
connect_args=connect_args
|
||||
)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
def get_db():
|
||||
|
||||
Reference in New Issue
Block a user