Files
backup-tool/backend/app/main.py
T
alex 19987d68a0 refactor(tests): use client fixture for test isolation
Replace all AsyncClient instantiations in test_sources.py and test_jobs.py
with the shared  fixture from conftest.py. This ensures proper test
database isolation via dependency overrides.

- Remove imports of httpx AsyncClient, ASGITransport, and app
- Add client fixture parameter to all test functions
- Remove async with blocks around HTTP requests
- test_engine.py already uses db fixture correctly, no changes needed
2026-05-11 21:38:15 +02:00

39 lines
1.1 KiB
Python

import os
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
from app.database import engine, Base
from app import models # noqa: F401 - registers models with Base.metadata
from app.routers import sources, jobs, executions, backups, settings, dashboard
@asynccontextmanager
async def lifespan(app: FastAPI):
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
yield
app = FastAPI(
title="Backup Tool API",
version="0.1.0",
lifespan=lifespan
)
app.add_middleware(
CORSMiddleware,
allow_origins=os.environ.get("CORS_ORIGINS", "http://localhost:3000").split(","),
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(sources.router)
app.include_router(jobs.router)
app.include_router(executions.router)
app.include_router(backups.router)
app.include_router(settings.router)
app.include_router(dashboard.router)
@app.get("/api/health")
async def health_check():
return {"status": "healthy"}