feat: group private apps into andreknie-privat
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""Shared test fixtures for OrgMyLife tests.
|
||||
|
||||
Provides:
|
||||
- Fresh in-memory SQLite DB per test session (avoids stale schema issues)
|
||||
- Authenticated test client (bypasses session auth via API_SECRET)
|
||||
"""
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Set API_SECRET before importing app so verify_session accepts Bearer token
|
||||
os.environ["API_SECRET"] = "test-secret"
|
||||
os.environ["DATABASE_URL"] = "sqlite:///./test_orgmylife.db"
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from app.db.session import Base, engine, SessionLocal
|
||||
from app.main import app
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def fresh_db():
|
||||
"""Drop and recreate all tables for each test to avoid schema drift."""
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
Base.metadata.create_all(bind=engine)
|
||||
yield
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
"""Authenticated test client with Bearer token."""
|
||||
c = TestClient(app)
|
||||
c.headers["Authorization"] = "Bearer test-secret"
|
||||
return c
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def db():
|
||||
"""Database session for direct DB assertions."""
|
||||
session = SessionLocal()
|
||||
yield session
|
||||
session.close()
|
||||
Reference in New Issue
Block a user