mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Fix tests
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from sqlalchemy.orm import Session
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
from .models.base import Base
|
||||
from .database import engine, SessionLocal
|
||||
@@ -9,9 +10,11 @@ from .routers import admin, employees, requests, auth, statistics
|
||||
from .db.init_db import init_db
|
||||
from .core.config import settings
|
||||
|
||||
# Создаем таблицы только если не в тестовом режиме
|
||||
if not settings.TESTING:
|
||||
def get_application(app_settings: BaseSettings = settings) -> FastAPI:
|
||||
"""Создание экземпляра приложения с заданными настройками."""
|
||||
# Создаем таблицы
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
# Инициализируем базу данных
|
||||
db = SessionLocal()
|
||||
try:
|
||||
@@ -19,37 +22,41 @@ if not settings.TESTING:
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
app = FastAPI(
|
||||
# Включаем автоматическое перенаправление со слэшем
|
||||
redirect_slashes=True,
|
||||
# Добавляем описание API
|
||||
title="Support System API",
|
||||
description="API для системы поддержки",
|
||||
version="1.0.0"
|
||||
)
|
||||
app = FastAPI(
|
||||
# Включаем автоматическое перенаправление со слэшем
|
||||
redirect_slashes=True,
|
||||
# Добавляем описание API
|
||||
title="Support System API",
|
||||
description="API для системы поддержки",
|
||||
version="1.0.0"
|
||||
)
|
||||
|
||||
# CORS configuration
|
||||
origins = [
|
||||
"http://localhost",
|
||||
"http://localhost:8080",
|
||||
"http://localhost:5173",
|
||||
"http://127.0.0.1:5173",
|
||||
"http://127.0.0.1:8080",
|
||||
"http://185.139.70.62", # Добавляем ваш production домен
|
||||
]
|
||||
# CORS configuration
|
||||
origins = [
|
||||
"http://localhost",
|
||||
"http://localhost:8080",
|
||||
"http://localhost:5173",
|
||||
"http://127.0.0.1:5173",
|
||||
"http://127.0.0.1:8080",
|
||||
"http://185.139.70.62", # Добавляем ваш production домен
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
expose_headers=["*"]
|
||||
)
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
expose_headers=["*"]
|
||||
)
|
||||
|
||||
# Include routers
|
||||
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
||||
app.include_router(employees.router, prefix="/api/employees", tags=["employees"])
|
||||
app.include_router(requests.router, prefix="/api/requests", tags=["requests"])
|
||||
app.include_router(admin.router, prefix="/api/admin", tags=["admin"])
|
||||
app.include_router(statistics.router, prefix="/api/statistics", tags=["statistics"])
|
||||
# Include routers
|
||||
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
||||
app.include_router(employees.router, prefix="/api/employees", tags=["employees"])
|
||||
app.include_router(requests.router, prefix="/api/requests", tags=["requests"])
|
||||
app.include_router(admin.router, prefix="/api/admin", tags=["admin"])
|
||||
app.include_router(statistics.router, prefix="/api/statistics", tags=["statistics"])
|
||||
|
||||
return app
|
||||
|
||||
app = get_application()
|
||||
Reference in New Issue
Block a user