feat(v5.2.0): finalize Infrastructure & Polish (tests isolation, xdist, lint, CI)
FlowDeck CI / lint (push) Successful in 43s
FlowDeck CI / test (push) Successful in 4m2s
FlowDeck CI / lint (pull_request) Successful in 42s
FlowDeck CI / test (pull_request) Successful in 4m3s
FlowDeck CI / docker (push) Successful in 1m2s
FlowDeck CI / docker (pull_request) Successful in 35s
FlowDeck CI / lint (push) Successful in 43s
FlowDeck CI / test (push) Successful in 4m2s
FlowDeck CI / lint (pull_request) Successful in 42s
FlowDeck CI / test (pull_request) Successful in 4m3s
FlowDeck CI / docker (push) Successful in 1m2s
FlowDeck CI / docker (pull_request) Successful in 35s
tests/conftest.py: mutate the settings singleton (instead of rebinding) so DB + backup dir are isolated per test -> pytest-xdist safe. Real backup tests (snapshot/prune/admin API) and OAuth mock tests (Gitea/GitHub/link) replace the previous skips. init_db() now also creates webhook_subscriptions (full schema without the FastAPI lifespan). ruff check is clean; .eslintrc.json migrated to eslint.config.mjs (flat config). CI: lint job (ruff + eslint), parallel tests (-n auto), run on every branch push. VERSION 5.11.1.
This commit is contained in:
+22
-7
@@ -1,9 +1,15 @@
|
||||
"""FlowDeck — pytest fixtures and configuration."""
|
||||
"""FlowDeck — pytest fixtures and configuration.
|
||||
|
||||
Each test gets a fresh, isolated SQLite database and backup directory so the
|
||||
suite is safe to run in parallel (``pytest -n auto``): workers never share a
|
||||
database file, and no state leaks between tests.
|
||||
"""
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -15,7 +21,7 @@ def client():
|
||||
|
||||
backup_dir = tempfile.mkdtemp(prefix="fd_backups_")
|
||||
|
||||
# Set env BEFORE importing app modules (config reads at import time)
|
||||
# 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"
|
||||
@@ -23,9 +29,21 @@ def client():
|
||||
os.environ["BACKUP_DIR"] = backup_dir
|
||||
os.environ["PROJECT_SYNC_ENABLED"] = "false"
|
||||
|
||||
# Force config reload by clearing the cached Settings instance
|
||||
# IMPORTANT: mutate the existing Settings singleton in place — do NOT rebind
|
||||
# `app.config.settings`. Modules such as `app.services.backup` and
|
||||
# `app.routers.auth` hold a direct reference imported at load time, so
|
||||
# rebinding would leave them pointing at the stale defaults (this was the
|
||||
# cause of the previously-skipped flaky backup tests).
|
||||
import app.config
|
||||
app.config.settings = app.config.Settings()
|
||||
s = app.config.settings
|
||||
s.database_url = f"sqlite:///{db_path}"
|
||||
s.app_secret_key = "test-secret-for-tests"
|
||||
s.rate_limit_enabled = False
|
||||
s.backup_enabled = True
|
||||
s.backup_dir = backup_dir
|
||||
s.backup_interval_hours = 24
|
||||
s.backup_keep = 30
|
||||
s.project_sync_enabled = False
|
||||
|
||||
from app.db import init_db
|
||||
from app.main import app
|
||||
@@ -47,6 +65,3 @@ def client():
|
||||
Path(backup_dir).rmdir()
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
Reference in New Issue
Block a user