Generate the full-data edition (pl9_personal_long_report.v4) and remove the reader edition. English still contains Han, so the API withholds it (BUG-1272, investigating). This commit is not pushed to staging.
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
"""Read-only packet slice for the consult card (TASK-report-full-data-edition T7)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from scripts.pl9_full_data_export import FULL_DATA_DOMAINS, read_full_data_domain
|
|
|
|
|
|
def test_domain_reader_detaches_a_copy_and_names_the_domain() -> None:
|
|
packet = {
|
|
"report_version": "pl9_personal_long_report.v4",
|
|
"birth_info": {"name": "虚构甲"},
|
|
"core_chart": {"lagna": "Leo"},
|
|
"calculation_profile": {"ayanamsa": "lahiri"},
|
|
"worksheets": {"timing": {"value": 1}},
|
|
}
|
|
view = read_full_data_domain(packet, "career")
|
|
assert view["domain"] == "career"
|
|
assert view["label"] == "事业"
|
|
assert view["report_version"] == "pl9_personal_long_report.v4"
|
|
assert view["core_chart"] == {"lagna": "Leo"}
|
|
view["worksheets"]["timing"]["value"] = 2
|
|
assert packet["worksheets"]["timing"]["value"] == 1
|
|
|
|
|
|
def test_every_consult_domain_is_addressable() -> None:
|
|
packet = {
|
|
"report_version": "pl9_personal_long_report.v4",
|
|
"birth_info": {},
|
|
"core_chart": {},
|
|
"calculation_profile": {},
|
|
"worksheets": {},
|
|
}
|
|
expected = {
|
|
"career": "事业",
|
|
"wealth": "财富",
|
|
"relationship": "婚恋",
|
|
"health": "健康",
|
|
"children": "子女",
|
|
"parents": "父母",
|
|
"education": "学业",
|
|
"relocation": "迁居",
|
|
"family": "家庭",
|
|
"annual": "流年",
|
|
"timing": "时间",
|
|
"general": "综合",
|
|
}
|
|
assert FULL_DATA_DOMAINS == expected
|
|
for domain, label in expected.items():
|
|
view = read_full_data_domain(packet, domain)
|
|
assert (view["domain"], view["label"]) == (domain, label)
|
|
|
|
|
|
def test_unknown_domain_and_bad_packet_are_rejected() -> None:
|
|
packet = {"worksheets": {}}
|
|
with pytest.raises(KeyError):
|
|
read_full_data_domain(packet, "romance")
|
|
with pytest.raises(TypeError):
|
|
read_full_data_domain([], "career") # type: ignore[arg-type]
|