fix(data): 监控日历循环依赖修(dbbardata 晚间源滞后会塌全体期望)——日历=确认集∪近15日工作日假定集,未确认日缺失降黄/确认日缺失才红(跨域互证),首跑实案三测试钉死 [vps]
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -160,6 +160,57 @@ def test_breaker_emits_own_key(tree, tmp_path):
|
||||
assert any(r["check_key"] == "data-akshare-breaker" for r in rows)
|
||||
|
||||
|
||||
def test_assumed_today_downgrades_unconfirmed_misses(tree, tmp_path):
|
||||
"""09-25 首跑实案: 日历锚(dbbardata 000300)晚间尚未合并今日 →
|
||||
per_date 数据在今日=绿; db_sample 缺今日=降黄(未确认日); 整体 rc=0."""
|
||||
db = tmp_path / "alerts.db"
|
||||
conn = sqlite3.connect(tree / "quant_trading.db")
|
||||
conn.execute("DELETE FROM dbbardata WHERE datetime='2026-09-25'")
|
||||
conn.commit()
|
||||
conn.close()
|
||||
rc = _run(tree, db)
|
||||
assert rc == 0 # 无红: 未确认日缺失只黄
|
||||
health = json.loads((tree / "monitor" / "health_latest.json").read_text())
|
||||
by_key = {c["key"]: c for c in health["checks"]}
|
||||
assert by_key["data-xueqiu_hot-stale"]["status"] == "green" # 数据在=绿
|
||||
assert by_key["data-dbbardata_daily-stale"]["status"] == "yellow" # 降黄
|
||||
assert by_key["data-dbbardata_index-stale"]["status"] == "yellow"
|
||||
|
||||
|
||||
def test_per_date_unconfirmed_miss_is_yellow(tree, tmp_path):
|
||||
"""节假日容忍: 当日既无 dbbardata 确认又无本域数据 → 黄(疑似节假日)非红."""
|
||||
db = tmp_path / "alerts.db"
|
||||
conn = sqlite3.connect(tree / "quant_trading.db")
|
||||
conn.execute("DELETE FROM dbbardata WHERE datetime='2026-09-25'")
|
||||
conn.commit()
|
||||
conn.close()
|
||||
for f in (tree / "static" / "xueqiu_hot").glob("20260925*"):
|
||||
f.unlink()
|
||||
rc = _run(tree, db)
|
||||
assert rc == 0 # 黄不抬码
|
||||
conn2 = store.connect(str(db))
|
||||
rows, _ = store.list_alerts(conn2, severity="yellow")
|
||||
row = [r for r in rows if r["check_key"] == "data-xueqiu_hot-stale"][0]
|
||||
assert row["evidence"]["evidence"]["unconfirmed_day"] is True
|
||||
|
||||
|
||||
def test_morning_confirmed_miss_upgrades_red(tree, tmp_path):
|
||||
"""次日晨班: 日历坐实今日(000300 已入) 但样本缺 → 升红."""
|
||||
db = tmp_path / "alerts.db"
|
||||
conn = sqlite3.connect(tree / "quant_trading.db")
|
||||
# 日历坐实: 保留 000300/000905 的 0925 行, 删掉一个股票样本的
|
||||
conn.execute("DELETE FROM dbbardata WHERE datetime='2026-09-25'"
|
||||
" AND symbol='600519'")
|
||||
conn.commit()
|
||||
conn.close()
|
||||
rc = _run(tree, db, shift="morning")
|
||||
assert rc == 3
|
||||
conn2 = store.connect(str(db))
|
||||
rows, _ = store.list_alerts(conn2)
|
||||
row = [r for r in rows if r["check_key"] == "data-dbbardata_daily-stale"][0]
|
||||
assert row["severity"] == "red"
|
||||
|
||||
|
||||
def test_inbox_ingestion_upserts_nas_events(tree, tmp_path):
|
||||
inbox = tree / "monitor" / "inbox"
|
||||
inbox.mkdir(parents=True)
|
||||
|
||||
Reference in New Issue
Block a user