Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""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()
|