M1 最小闭环:CLI + FastAPI 网关 + SQL 闸 + 100% 覆盖率验收链
- 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 已核验
This commit is contained in:
commit
d37c697bbe
59 files changed
+7586
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"""paths.py:目录规范与 dbpath 解析。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from pyquantdata.paths import DbPathLayout, resolve_dbpath
|
||||
|
||||
|
||||
def test_layout_properties(tmp_path):
|
||||
lay = DbPathLayout(tmp_path / "db")
|
||||
assert lay.config_file.name == "config.json"
|
||||
assert lay.catalog.name == "catalog.duckdb"
|
||||
assert lay.lock_file.name == "quantdata.lock"
|
||||
assert lay.trash_dir.name == ".trash"
|
||||
assert lay.data_dir.parent == lay.root
|
||||
|
||||
|
||||
def test_ensure_dirs_creates_all(tmp_path):
|
||||
lay = DbPathLayout(tmp_path / "db")
|
||||
made = lay.ensure_dirs()
|
||||
for d in (lay.root, lay.data_dir, lay.scripts_dir, lay.exports_dir, lay.logs_dir, lay.tmp_dir, lay.trash_dir):
|
||||
assert d.exists()
|
||||
assert lay.root in made
|
||||
|
||||
|
||||
def test_ensure_dirs_idempotent(tmp_path):
|
||||
lay = DbPathLayout(tmp_path / "db")
|
||||
lay.ensure_dirs()
|
||||
made2 = lay.ensure_dirs()
|
||||
assert len(made2) == 7
|
||||
|
||||
|
||||
def test_resolve_explicit_wins(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("QUANTDATA_HOME", str(tmp_path / "from_env"))
|
||||
assert resolve_dbpath(str(tmp_path / "explicit")) == (tmp_path / "explicit").resolve()
|
||||
|
||||
|
||||
def test_resolve_env_fallback(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("QUANTDATA_HOME", str(tmp_path / "from_env"))
|
||||
assert resolve_dbpath(None) == (tmp_path / "from_env").resolve()
|
||||
|
||||
|
||||
def test_resolve_missing_raises(monkeypatch):
|
||||
monkeypatch.delenv("QUANTDATA_HOME", raising=False)
|
||||
with pytest.raises(SystemExit):
|
||||
resolve_dbpath(None)
|
||||
Reference in new issue
Block a user