All checks were successful
CI / Windows build (push) Successful in 7m47s
Redesign the optional FastAPI companion around vault files (manifest / PUT/GET/DELETE + OCR jobs) instead of legacy strokes_json notes. Wire a client Server settings panel for health/login. Polish shell UX: l10n for settings/home/board, sticky-board empty state, and a narrow-screen diagnostics FAB. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""Shared test fixtures for BadNote tests."""
|
|
|
|
import os
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
|
|
import pytest
|
|
import pytest_asyncio
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
# Ensure the server package is importable
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
os.environ["BADNOTE_STORAGE_PATH"] = "/tmp/badnote_test_storage"
|
|
os.environ["BADNOTE_QUEUE_PATH"] = "/tmp/badnote_test_queue"
|
|
os.environ["BADNOTE_VAULT_PATH"] = "/tmp/badnote_test_vaults"
|
|
os.environ["BADNOTE_JWT_SECRET"] = "test-secret-key-for-testing-only"
|
|
|
|
from badnote_server.config import settings # noqa: E402
|
|
from badnote_server.main import app # noqa: E402
|
|
from badnote_server.database import get_db, close_db, init_db # noqa: E402
|
|
|
|
|
|
@pytest_asyncio.fixture(autouse=True)
|
|
async def setup_db(tmp_path):
|
|
"""Fresh DB and clean queue for each test."""
|
|
db_path = str(tmp_path / "test.db")
|
|
settings.db_path = db_path
|
|
settings.vault_path = str(tmp_path / "vaults")
|
|
# Clean the queue directory before each test
|
|
queue_path = settings.queue_path
|
|
if os.path.exists(queue_path):
|
|
shutil.rmtree(queue_path)
|
|
if os.path.exists(settings.vault_path):
|
|
shutil.rmtree(settings.vault_path)
|
|
await init_db()
|
|
yield
|
|
await close_db()
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def client():
|
|
"""Async test client for the FastAPI app."""
|
|
transport = ASGITransport(app=app)
|
|
async with AsyncClient(transport=transport, base_url="http://test") as ac:
|
|
yield ac
|