generated from kgod/ai-review-template
自内部仓库剥离深度优化与 RAG 知识库后的交付版本: - Builder 对话式简历生成(FSM + 意图路由 LLM 兜底增强) - 条目级轻度优化:事实覆盖门禁 + STAR/bullet 修复链,功能/简介/成果与技术栈同级保护 - 简历导入:DOCX/PDF 解析、结构归一、手机号脱敏 - PostgreSQL 运行时 + Alembic 迁移链 Co-Authored-By: Claude <noreply@anthropic.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from uuid import uuid4
|
|
|
|
from alembic import command
|
|
from alembic.config import Config
|
|
from sqlalchemy import create_engine, text
|
|
|
|
|
|
def test_alembic_upgrade_creates_core_postgres_schema() -> None:
|
|
schema = f"test_alembic_{uuid4().hex}"
|
|
database_url = os.environ["RESUME_AGENT_TEST_DATABASE_URL"]
|
|
config = Config(str(Path(__file__).resolve().parents[1] / "alembic.ini"))
|
|
config.set_main_option("sqlalchemy.url", database_url)
|
|
config.set_main_option("resume_agent.schema", schema)
|
|
|
|
command.upgrade(config, "head")
|
|
|
|
engine = create_engine(database_url)
|
|
try:
|
|
with engine.connect() as connection:
|
|
tables = connection.execute(
|
|
text(
|
|
"SELECT tablename FROM pg_tables "
|
|
"WHERE schemaname = :schema ORDER BY tablename"
|
|
),
|
|
{"schema": schema},
|
|
).scalars().all()
|
|
assert tables == [
|
|
"alembic_version",
|
|
"blocks",
|
|
"optimization_runs",
|
|
"resume_imports",
|
|
"resumes",
|
|
"sessions",
|
|
"turns",
|
|
]
|
|
finally:
|
|
with engine.begin() as connection:
|
|
connection.execute(text(f'DROP SCHEMA IF EXISTS "{schema}" CASCADE'))
|
|
engine.dispose()
|