fix(report): keep monthly KP headings and readable timing sources
Heading-ensure only covered empty packets, so present KP months still dropped MD/AD titles and sanitizer blanked source_path. Also lock the quality gate onto the new contracts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -62,7 +62,12 @@ def test_report_projection_is_hash_stable_and_renders_only_candidate_window_evid
|
||||
|
||||
assert build_flexible_birth_time_full_report_projection(reordered)["projection_id"] == projection["projection_id"]
|
||||
assert projection["status"] == "candidate_window_only"
|
||||
assert "出生时间敏感度" in render_flexible_birth_time_report_section(projection)
|
||||
rendered = render_flexible_birth_time_report_section(projection)
|
||||
assert "出生时间敏感度" in rendered
|
||||
assert "#### 校时附录·分钟排行" in rendered
|
||||
assert "08:00" in rendered
|
||||
assert "winner" not in rendered.lower()
|
||||
assert "approved" not in rendered.lower()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field", ["approved_birth_time", "final_birth_time", "winner", "approval"])
|
||||
|
||||
@@ -8,6 +8,7 @@ from scripts.jyotish_engine import (
|
||||
PLANNED_LONGFORM_SECTION_HEADINGS,
|
||||
_annual_series_surface,
|
||||
_attach_report_governance_contracts,
|
||||
_birth_provenance_from_args,
|
||||
_native_dasha_master_families,
|
||||
render_pl9_markdown,
|
||||
sanitize_professional_report_reference,
|
||||
@@ -168,3 +169,81 @@ def test_auxiliary_dasha_headings_render_from_native_modules() -> None:
|
||||
assert "#### Narayana Rashi Dasha" in markdown
|
||||
assert "#### Kala Chakra Dasha(本地原始周期,冲突保留)" in markdown
|
||||
assert "#### Bhava Bala(本地三分量评分)" in markdown
|
||||
|
||||
|
||||
def test_quality_gate_runs_this_file() -> None:
|
||||
from scripts.run_quality_gate import CORE_PYTEST_TARGETS
|
||||
|
||||
assert "tests/test_report_longform_gaps2.py" in CORE_PYTEST_TARGETS
|
||||
assert "tests/test_report_longform_parity.py" in CORE_PYTEST_TARGETS
|
||||
assert "tests/test_timing_precision_contract.py" in CORE_PYTEST_TARGETS
|
||||
assert "tests/test_flexible_birth_time_report_contract.py" in CORE_PYTEST_TARGETS
|
||||
|
||||
|
||||
def test_kp_monthly_theme_brief_keeps_heading_when_months_exist() -> None:
|
||||
markdown = render_pl9_markdown(_producer_packet({
|
||||
"advanced_systems": {
|
||||
"kp_monthly_report": {
|
||||
"months": [
|
||||
{
|
||||
"month": "2026-01",
|
||||
"theme_support": {
|
||||
"career": {"brief_summary": "career-support", "active_houses": [10]},
|
||||
"wealth": {"brief_summary": "wealth-support", "active_houses": [2]},
|
||||
"relationship": {"brief_summary": "relationship-support", "active_houses": [7]},
|
||||
},
|
||||
"vimshottari_five_levels": {
|
||||
"levels": {
|
||||
"mahadasha": {"lord": "Saturn"},
|
||||
"antardasha": {"lord": "Mercury"},
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}))
|
||||
assert "#### KP 事业逐月 MD/AD 支持" in markdown
|
||||
assert "#### KP 财务逐月 MD/AD 支持" in markdown
|
||||
assert "#### KP 关系逐月 MD/AD 支持" in markdown
|
||||
assert "career-support" in markdown
|
||||
assert markdown.count("#### KP 事业逐月 MD/AD 支持") == 1
|
||||
assert "kp_monthly_payload_empty" not in markdown
|
||||
assert "planned_section_unavailable" not in markdown.split("#### KP 事业逐月 MD/AD 支持", 1)[-1].split("#### KP 财务逐月 MD/AD 支持", 1)[0]
|
||||
|
||||
|
||||
def test_sanitized_packet_keeps_timing_source_labels() -> None:
|
||||
packet = _attach_report_governance_contracts(
|
||||
_producer_packet({}),
|
||||
SimpleNamespace(**BEIJING, birth_time_accuracy="confirmed"),
|
||||
)
|
||||
sanitized = sanitize_professional_report_reference(packet)
|
||||
markdown = render_pl9_markdown(sanitized)
|
||||
assert "full-reading Dasha module" in markdown
|
||||
assert "full-reading Narayana module" in markdown
|
||||
assert "annual Tajika series" in markdown
|
||||
assert "KP exact cusp oracle status" in markdown
|
||||
assert "raw_full_reading.modules" not in markdown
|
||||
assert "references/oracle" not in markdown
|
||||
|
||||
|
||||
def test_birth_provenance_uses_candidate_window_minutes() -> None:
|
||||
provenance = _birth_provenance_from_args(SimpleNamespace(
|
||||
birthplace_label="测试市",
|
||||
coordinate_source="user_reported",
|
||||
coordinate_precision="unverified_user_coordinates",
|
||||
time_source="user_reported",
|
||||
candidate_range={"start_time": "11:50", "end_time": "12:10"},
|
||||
))
|
||||
assert provenance["uncertainty_minutes"] == 20
|
||||
assert provenance["coordinate_source"] == "user_reported"
|
||||
|
||||
|
||||
def test_birth_provenance_uses_declared_window_minutes() -> None:
|
||||
provenance = _birth_provenance_from_args(SimpleNamespace(
|
||||
declared_window_start="11:50",
|
||||
declared_window_end="12:10",
|
||||
coordinate_source="user_reported",
|
||||
))
|
||||
assert provenance["uncertainty_minutes"] == 20
|
||||
assert provenance["coordinate_source"] == "user_reported"
|
||||
|
||||
@@ -26,6 +26,12 @@ def test_timing_contract_preserves_dates_but_caps_claim_status() -> None:
|
||||
assert contract["promotion_gate"]["status"] == "blocked"
|
||||
|
||||
|
||||
def test_quality_gate_runs_this_file() -> None:
|
||||
from scripts.run_quality_gate import CORE_PYTEST_TARGETS
|
||||
|
||||
assert "tests/test_timing_precision_contract.py" in CORE_PYTEST_TARGETS
|
||||
|
||||
|
||||
def test_empty_timing_contract_still_exposes_boundary() -> None:
|
||||
contract = build_timing_precision_contract()
|
||||
assert contract["timing_precision"] == "broad_window_only"
|
||||
|
||||
Reference in New Issue
Block a user