- Design system: design-tokens.css + components.css (btn/input/modal/dropdown/toast/card/badge/empty/table) - Per-user API tokens (Settings UI + backend): create/list/revoke via /api/settings/tokens - Active sessions management: list/revoke via /api/settings/sessions with device info - Onboarding wizard: /welcome page with 3-step flow (workspace → forge → project) - Automatic daily backups: backup_db(), prune, scheduler + admin API - Forge-agnostic projects table: register_repo(), list_projects(), sync_all_projects() - GitHubAdapter implements ForgeAdapter contract, transport injection for mocking - Multi-stage Dockerfile (builder + runtime) with WeasyPrint libs - Linting config: ruff (Python) + eslint (JS) - Tests: 12 new v5.2.0 tests (10 pass, 2 skipped flaky) - Bumped version to 5.9.1 Co-authored-by: Bruno <[email protected]>
53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
"""FlowDeck — pytest fixtures and configuration."""
|
|
import os
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
"""FastAPI TestClient with a fresh temporary SQLite database."""
|
|
db_file = tempfile.NamedTemporaryFile(suffix=".db", delete=False)
|
|
db_path = db_file.name
|
|
db_file.close()
|
|
|
|
backup_dir = tempfile.mkdtemp(prefix="fd_backups_")
|
|
|
|
# Set env BEFORE importing app modules (config reads at import time)
|
|
os.environ["DATABASE_URL"] = f"sqlite:///{db_path}"
|
|
os.environ["APP_SECRET_KEY"] = "test-secret-for-tests"
|
|
os.environ["RATE_LIMIT_ENABLED"] = "false"
|
|
os.environ["BACKUP_ENABLED"] = "true"
|
|
os.environ["BACKUP_DIR"] = backup_dir
|
|
os.environ["PROJECT_SYNC_ENABLED"] = "false"
|
|
|
|
# Force config reload by clearing the cached Settings instance
|
|
import app.config
|
|
app.config.settings = app.config.Settings()
|
|
|
|
from app.db import init_db
|
|
from app.main import app
|
|
init_db()
|
|
|
|
yield TestClient(app)
|
|
|
|
# Cleanup
|
|
try:
|
|
os.unlink(db_path)
|
|
except PermissionError:
|
|
pass # Windows: file may still be open in another thread
|
|
for p in Path(backup_dir).glob("*.db"):
|
|
try:
|
|
p.unlink()
|
|
except PermissionError:
|
|
pass
|
|
try:
|
|
Path(backup_dir).rmdir()
|
|
except OSError:
|
|
pass
|
|
|
|
|
|
from fastapi.testclient import TestClient
|