generated from kgod/ai-review-template
feat: initialize resume agent with OfferPai sync
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user