61 lines
3.0 KiB
Python
61 lines
3.0 KiB
Python
"""Report and product BPHS provenance and the selected profile."""
|
|
|
|
from hashlib import sha256
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from scripts.functional_benefics import derive_functional_benefic_malefic
|
|
from scripts.report_render.audit_chapters import render_audit_chapters
|
|
from tests.test_reading_facts_v3_20261112 import _reading_facts, _reading_request, public_report
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
PRODUCT_PROFILE_PATH = "references/product_functional_profile_bphs_v3_166q4.md"
|
|
|
|
|
|
def test_upstream_profile_retains_exact_source_bytes():
|
|
source = ROOT / "references/functional-role-profile.md"
|
|
# yinduzhanxing 8aaf60991c32a84ac30d6d7b6a62c4f166507bce.
|
|
assert sha256(source.read_bytes()).hexdigest() == "95f5445a197a5f49ebaa08431816f0f3583b0a3c13f7967d3c043cecfe63aa7e"
|
|
product = (ROOT / PRODUCT_PROFILE_PATH).read_text(encoding="utf-8")
|
|
assert "bphs_ch34_general_with_sign_exceptions_v3_166q4" in product
|
|
assert "Revision v3" in product and "Chart page layout (issue #163)" in product
|
|
|
|
|
|
@pytest.mark.parametrize(("ascendant", "role"), [
|
|
("Aries", "malefic"), ("Taurus", "benefic"), ("Gemini", "mixed"),
|
|
("Cancer", "malefic"), ("Leo", "malefic"), ("Virgo", "mixed"),
|
|
("Libra", "benefic"), ("Scorpio", "malefic"), ("Sagittarius", "malefic"),
|
|
("Capricorn", "benefic"), ("Aquarius", "benefic"), ("Pisces", "malefic"),
|
|
])
|
|
def test_product_bphs_saturn_table_is_unchanged(ascendant, role):
|
|
result = derive_functional_benefic_malefic(ascendant, functional_profile="bphs_exception_profile")
|
|
group = "neutral" if role == "mixed" else role
|
|
assert "Saturn" in result[f"functional_{group}s"]
|
|
if role == "mixed":
|
|
assert "mixed" in result["ambiguous_cell_notes"]["Saturn"]["summary_en"]
|
|
assert result["profile"] == "bphs_ch34_general_with_sign_exceptions_v3_166q4"
|
|
assert result["rule_reference"] == PRODUCT_PROFILE_PATH
|
|
assert PRODUCT_PROFILE_PATH in result["profile_source"]
|
|
|
|
|
|
def test_report_functional_profile_follows_packet(public_report):
|
|
_, body, reading, packet = public_report
|
|
assert _reading_facts(packet, reading, **_reading_request(body))["functional"]["functional_profile"] == "pvr_table30_v1"
|
|
|
|
|
|
def test_personal_appendix_reports_only_recorded_verification_status():
|
|
packet = {"technique_audit_table": [
|
|
{"technique": "MEVG / Global Web Evidence", "status": "blocked", "note": "internal"},
|
|
{"technique": "Real Case Calibration", "calculation_status": "partial", "status": "executed"},
|
|
]}
|
|
zh = render_audit_chapters(packet, "zh")
|
|
assert "| 网上资料核对 | 未完成 |" in zh
|
|
assert "| 真实案例校准 | 部分完成 |" in zh
|
|
assert "MEVG" not in zh and "internal" not in zh
|
|
packet["technique_audit_table"][0]["status"] = "executed"
|
|
assert "| 网上资料核对 | 已完成 |" in render_audit_chapters(packet, "zh")
|
|
fallback = render_audit_chapters({}, "zh")
|
|
assert "| 网上资料核对 | 未完成 |" in fallback and "| 真实案例校准 | 未完成 |" in fallback
|