Files

30 lines
599 B
Python
Raw Permalink Normal View History

2026-04-19 12:13:07 +02:00
from pathlib import Path
import pytest
from fastapi.testclient import TestClient
2026-04-19 12:36:55 +02:00
from sqlalchemy.orm import Session
2026-04-19 12:13:07 +02:00
2026-04-19 12:36:55 +02:00
from app.db import SessionLocal, configure_database
2026-04-19 12:13:07 +02:00
from app.main import create_app
@pytest.fixture
def client(tmp_path: Path):
test_db_path = tmp_path / "test.db"
database_url = f"sqlite:///{test_db_path}"
configure_database(database_url)
app = create_app()
with TestClient(app) as test_client:
yield test_client
2026-04-19 12:36:55 +02:00
@pytest.fixture
def db_session(client) -> Session:
db = SessionLocal()
try:
yield db
finally:
db.close()