33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
_backend = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(_backend))
|
|
_root = _backend.parent / "Temp" / "pytest"
|
|
_root.mkdir(parents=True, exist_ok=True)
|
|
os.environ["EUNIV_SECRET_KEY"] = "test-secret-key"
|
|
os.environ["EUNIV_DB_PATH"] = str(_root / "euniv.db")
|
|
os.environ["EUNIV_DISABLE_REFRESH"] = "1"
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def fresh_database():
|
|
from sqlalchemy import text
|
|
|
|
from admin.settings import ensure_admin_seed, load_admin_identity
|
|
from euniv.db import engine, init_db
|
|
|
|
with engine.begin() as connection:
|
|
connection.execute(text("DROP TABLE IF EXISTS accounts"))
|
|
connection.execute(text("DROP TABLE IF EXISTS schedules"))
|
|
connection.execute(text("DROP TABLE IF EXISTS system_config"))
|
|
connection.execute(text("DROP TABLE IF EXISTS courses"))
|
|
connection.execute(text("DROP TABLE IF EXISTS course_sync"))
|
|
connection.execute(text("DROP TABLE IF EXISTS alembic_version"))
|
|
init_db()
|
|
ensure_admin_seed()
|
|
load_admin_identity()
|