mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-05 09:22:04 +02:00
Do testing on isolated DB
This commit is contained in:
@@ -1,7 +1,26 @@
|
||||
"""Pytest configuration and shared fixtures."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
# Use an isolated file-backed SQLite DB for tests that import app.main/TestClient.
|
||||
# This must be set before app.config/app.database are imported, otherwise the global
|
||||
# Database instance will bind to the default runtime DB (data/meshcore.db).
|
||||
_TEST_DB_DIR = Path(tempfile.mkdtemp(prefix="meshcore-pytest-"))
|
||||
_TEST_DB_PATH = _TEST_DB_DIR / "meshcore.db"
|
||||
os.environ.setdefault("MESHCORE_DATABASE_PATH", str(_TEST_DB_PATH))
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def cleanup_test_db_dir():
|
||||
"""Clean up temporary pytest DB directory after the test session."""
|
||||
yield
|
||||
shutil.rmtree(_TEST_DB_DIR, ignore_errors=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_channel_key():
|
||||
|
||||
Reference in New Issue
Block a user