feat: 增加管理后台的会话、配置和用户管理
This commit is contained in:
@@ -2,6 +2,8 @@ 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"
|
||||
@@ -9,3 +11,20 @@ _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 alembic_version"))
|
||||
init_db()
|
||||
ensure_admin_seed()
|
||||
load_admin_identity()
|
||||
|
||||
Reference in New Issue
Block a user