693cd952cd
仓库首次入库(此前仅存在于本地工作区与测试服构建产物中,未上传)。 改动(src/knowledge_adapter/asset_content_processor.py): - 新增 _TRUNCATED_TRAILING_MARKDOWN_RESOURCE_IMAGE 规则,清除 chunk 末尾被截断的  - 回归测试 tests/test_asset_content_processor.py:: test_truncated_trailing_markdown_resource_image_is_removed 验证证据: - 测试服 120.76.217.51,镜像 knowledge-adapter-service:reviewed-test-aeab4b5fca2d (release aeab4b5fca2d8661):KB d015d05c-25c8-4d63-b2ab-e8590d3c2dfb 5 个查询全部 http=200、records=5、残留 resource:// = 0;KB b9dacd62 无退化;容器日志无 error/exception - 本地:pytest 141 项全通过、ruff 全通过 - 该文件与 258c31e0fe07fd08 源码的差异经逐文件 md5 比对,为唯一变更文件
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
from pathlib import Path
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
UP_MIGRATION = PROJECT_ROOT / "migrations" / "0001_asset_mapping.up.sql"
|
|
DOWN_MIGRATION = PROJECT_ROOT / "migrations" / "0001_asset_mapping.down.sql"
|
|
|
|
|
|
def normalized_sql(path: Path) -> str:
|
|
return " ".join(path.read_text(encoding="utf-8").lower().split())
|
|
|
|
|
|
def test_asset_mapping_up_migration_has_minimal_idempotent_schema() -> None:
|
|
assert UP_MIGRATION.exists(), "asset_mapping up migration is missing"
|
|
|
|
sql = normalized_sql(UP_MIGRATION)
|
|
assert "create table if not exists asset_mapping" in sql
|
|
assert "asset_id uuid primary key" in sql
|
|
assert "source_ref text not null" in sql
|
|
assert "object_key text not null" in sql
|
|
assert "content_type text" in sql
|
|
assert "created_at timestamptz not null default current_timestamp" in sql
|
|
assert "status text not null default 'active'" in sql
|
|
assert "check (status in ('active', 'disabled'))" in sql
|
|
assert "create unique index if not exists" in sql
|
|
assert "on asset_mapping (source_ref)" in sql
|
|
|
|
for forbidden_identifier in (
|
|
"presigned_url",
|
|
"access_key",
|
|
"secret_key",
|
|
"authorization",
|
|
"bucket",
|
|
):
|
|
assert forbidden_identifier not in sql
|
|
|
|
|
|
def test_asset_mapping_down_migration_is_idempotent_and_scoped() -> None:
|
|
assert DOWN_MIGRATION.exists(), "asset_mapping down migration is missing"
|
|
|
|
sql = normalized_sql(DOWN_MIGRATION)
|
|
assert sql == "drop table if exists asset_mapping;"
|