34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Rule-tier claims for numbers the kernel reproduces."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from lead.ledger.store import open_ledger
|
|
from lead.rules import publish_rules
|
|
|
|
|
|
def test_publish_rules_inserts_each_published_threshold_once(tmp_path):
|
|
con = open_ledger(str(tmp_path / "ledger.duckdb"))
|
|
try:
|
|
inserted = publish_rules(con, actor="tester")
|
|
rows = con.execute(
|
|
"""
|
|
SELECT target_id, effect_value, tiers, subject
|
|
FROM lead_evidence.claim
|
|
ORDER BY target_id
|
|
"""
|
|
).fetchall()
|
|
by_target = {row[0]: row for row in rows}
|
|
assert inserted == len(rows) == 5
|
|
assert by_target["RA.CAP"][1] == 0.04
|
|
assert by_target["HN.4"][1] == 3.0
|
|
assert by_target["HN.5"][1] == 0.35
|
|
assert by_target["HN.6"][1] == 2.0
|
|
assert by_target["HN.7"][1] == 45.0
|
|
assert all(row[2] == "rule" for row in rows)
|
|
subject = by_target["HN.6"][3]
|
|
assert "3.0" in subject
|
|
assert "0.35" in subject
|
|
assert publish_rules(con, actor="other") == 0
|
|
finally:
|
|
con.close()
|