- CLI:init/serve/update/query/export/status(typer + rich),单写者锁三元判活 - 存储:DuckDB schema migrations(14 表 + 8 联邦视图,语句元组逐条执行) - ETL:A股证券/日历/日K,整区替换幂等;日历全年补全(calendar 语义唯一) - 网关:POST /v1/query(线程池 + interrupt 超时 504)、/v1/export、meta/stats/state、healthz/ready - 安全:SQL 闸 sqlglot fail-closed(文件/网络表函数默认拒)、非 loopback 空 token 拒启、导出路径双判 - 验收:254 测试全绿、1265 语句 100% 覆盖、[CI] 真起服验收链、smoke_m1.py 交付自检 - 文档:设计文档 v0.7(圆桌 45 条采纳 + 3 条实施校准),README 重写 - 发布:release.yml Trusted Publishing(OIDC 免密钥),action refs 已核验
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""etl_checkpoint 语义。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pyquantdata.etl import failed_checkpoints, list_checkpoints, upsert_checkpoint
|
|
|
|
|
|
def test_upsert_and_list(catalog):
|
|
upsert_checkpoint(catalog, "bars_1d", "cn", "daily", "2026-09-22", 100)
|
|
upsert_checkpoint(catalog, "securities", "cn", "all", "", 5123)
|
|
cps = list_checkpoints(catalog)
|
|
assert [(c["dataset"], c["watermark"], c["rows"]) for c in cps] == [
|
|
("bars_1d", "2026-09-22", 100),
|
|
("securities", "", 5123),
|
|
]
|
|
assert all(c["status"] == "ok" for c in cps)
|
|
assert all(c["updated_at"] for c in cps)
|
|
|
|
|
|
def test_upsert_replaces(catalog):
|
|
upsert_checkpoint(catalog, "bars_1d", "cn", "daily", "2026-09-21", 50)
|
|
upsert_checkpoint(catalog, "bars_1d", "cn", "daily", "2026-09-22", 60)
|
|
cps = list_checkpoints(catalog)
|
|
assert len(cps) == 1
|
|
assert cps[0]["watermark"] == "2026-09-22"
|
|
assert cps[0]["rows"] == 60
|
|
|
|
|
|
def test_failed_filter(catalog):
|
|
upsert_checkpoint(catalog, "bars_1d", "cn", "daily", "x", 0, status="failed")
|
|
upsert_checkpoint(catalog, "calendar", "cn", "2026", "2026-12-31", 244)
|
|
failed = failed_checkpoints(catalog)
|
|
assert [c["dataset"] for c in failed] == ["bars_1d"]
|