fix(tests): isolate test DB and sync tier=pro in Pro user fixtures
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m34s

This commit is contained in:
2026-06-14 19:44:25 +02:00
parent f85e5eef9b
commit 233a054e34
3 changed files with 22 additions and 0 deletions

View File

@@ -1,3 +1,14 @@
import os
import tempfile
from pathlib import Path
# Use a temporary on-disk SQLite database for the test session so that
# both the sync and async engines used by the app point at the same isolated
# schema. This avoids relying on (or mutating) the developer's data/translate.db.
_test_db_file = tempfile.NamedTemporaryFile(suffix=".db", delete=False)
_test_db_file.close()
os.environ["SQLITE_PATH"] = _test_db_file.name
import pytest
import pytest_asyncio
from typing import AsyncGenerator
@@ -14,6 +25,11 @@ TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
def initialize_test_database():
Base.metadata.create_all(bind=sync_engine)
yield
# Clean up the temporary test database after the session.
try:
Path(_test_db_file.name).unlink(missing_ok=True)
except Exception:
pass
@pytest_asyncio.fixture