feat: add asset manifest knowledge ingest
This commit is contained in:
@@ -13,11 +13,13 @@ full backing-service compose stack to be online.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from alembic import command
|
||||
from alembic.config import Config
|
||||
from alembic.script import ScriptDirectory
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
@@ -29,9 +31,6 @@ def alembic_cfg(tmp_path, monkeypatch):
|
||||
db_file = tmp_path / "legacyhub.db"
|
||||
monkeypatch.setenv("POSTGRES_HOST", "127.0.0.1")
|
||||
monkeypatch.setenv("POSTGRES_PORT", "5432")
|
||||
# Force a fresh Settings + Alembic env that ignores the configured PG.
|
||||
from alembic.config import Config
|
||||
|
||||
cfg = Config(str(ROOT / "alembic.ini"))
|
||||
cfg.set_main_option("script_location", str(ROOT / "app" / "db" / "migrations"))
|
||||
cfg.set_main_option("sqlalchemy.url", f"sqlite:///{db_file}")
|
||||
@@ -40,11 +39,10 @@ def alembic_cfg(tmp_path, monkeypatch):
|
||||
|
||||
def test_migration_offline_emits_sql(alembic_cfg, tmp_path):
|
||||
"""Offline mode generates SQL for every table; verify ``documents`` appears
|
||||
and at least one JSONB-equivalent column is rendered. SQLite has no JSONB
|
||||
but Alembic's offline mode happily emits the raw DDL for inspection.
|
||||
and the TeamHUB AssetManifest ingest job table is part of the linear head.
|
||||
SQLite has no JSONB but Alembic's offline mode happily emits the raw DDL for
|
||||
inspection.
|
||||
"""
|
||||
from alembic import command
|
||||
|
||||
out_file = tmp_path / "upgrade.sql"
|
||||
# ``--sql`` mode bypasses dialect-specific runtime, perfect for a fast check.
|
||||
with out_file.open("w", encoding="utf-8") as f:
|
||||
@@ -59,17 +57,18 @@ def test_migration_offline_emits_sql(alembic_cfg, tmp_path):
|
||||
assert "CREATE TABLE documents" in sql
|
||||
assert "CREATE TABLE chunks" in sql
|
||||
assert "CREATE TABLE processing_events" in sql
|
||||
assert "CREATE TABLE asset_ingest_jobs" in sql
|
||||
# Constraint sanity
|
||||
assert "uq_chunks_doc_idx" in sql
|
||||
assert "uq_pages_doc_page" in sql
|
||||
assert "uq_asset_ingest_identity" in sql
|
||||
|
||||
|
||||
def test_revision_history_is_linear(alembic_cfg):
|
||||
"""The current project has a single linear history at 0001_initial."""
|
||||
from alembic.script import ScriptDirectory
|
||||
|
||||
"""The project keeps a single linear migration head."""
|
||||
script = ScriptDirectory.from_config(alembic_cfg)
|
||||
heads = script.get_heads()
|
||||
assert len(heads) == 1, f"expected one head, got: {heads}"
|
||||
initial = next(iter(script.walk_revisions()))
|
||||
assert initial.revision == "0001_initial"
|
||||
assert heads == ["0002_asset_ingest_jobs"]
|
||||
revisions = [rev.revision for rev in script.walk_revisions()]
|
||||
assert revisions == ["0002_asset_ingest_jobs", "0001_initial"]
|
||||
|
||||
Reference in New Issue
Block a user