Files
Jyotisha/tests/test_prepare_full_synastry_packets.py
T
jesse-uxGrok (agent loop)Cursor
362d903c31 fix(synastry): close the second review gaps on evidence, billing, and the sidebar
The second review still failed on missing database and route coverage, an unmarked relationship structure, a stuck English lease, and a sidebar that fetched the product switch itself.

Co-Authored-By: Grok (agent loop)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-19 14:48:11 +08:00

68 lines
3.0 KiB
Python

from __future__ import annotations
import importlib.util
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
MODULE_PATH = ROOT / "skills" / "jyotish-full-synastry-reading" / "scripts" / "prepare_full_synastry_packets.py"
spec = importlib.util.spec_from_file_location("prepare_full_synastry_packets", MODULE_PATH)
module = importlib.util.module_from_spec(spec)
assert spec and spec.loader
spec.loader.exec_module(module)
def _profile(**updates):
profile = {
"date": "2000-01-01", "time": "12:34:56", "place": "Example City, Example Country",
"latitude": 31.2, "longitude": 121.5, "timezone": 8.0,
"ayanamsa": "lahiri", "node_mode": "mean",
}
profile.update(updates)
return profile
def test_profile_normalization_requires_place_and_builds_native_full_reading_command():
profile = module.normalize_profile(_profile())
command = module.full_reading_command(profile, today="2026-10-17")
assert command[2] == "full-reading"
assert command[command.index("--ayanamsa") + 1] == "lahiri"
assert command[command.index("--node-mode") + 1] == "mean"
assert command[command.index("--today") + 1] == "2026-10-17"
with pytest.raises(ValueError, match="place"):
module.normalize_profile(_profile(place=""))
def test_runner_has_a_fixed_preflight_before_native_calculation():
command = module.preflight_command()
# 原值: Path(command[1]).name == "pre_work_check.py"
# 新值: 两边都换成正斜杠后再 endswith("scripts/pre_work_check.py")
# 原因: 修复单要求保留上游的 endswith 比较,同时让 Windows 反斜杠也能对上
assert command[1].replace("\\", "/").endswith("scripts/pre_work_check.py")
assert command[command.index("--remote-timeout") + 1] == "8"
assert command[command.index("--command-timeout") + 1] == "45"
def test_profile_normalization_accepts_minute_precision_and_rejects_invalid_nodes():
profile = module.normalize_profile(_profile(time="12:34"))
assert profile["second"] == 0
with pytest.raises(ValueError, match="node_mode"):
module.normalize_profile(_profile(node_mode="hybrid"))
def test_private_output_directory_refuses_repository_paths(tmp_path):
assert module._private_output_directory(str(tmp_path)) == tmp_path.resolve()
with pytest.raises(ValueError, match="outside the repository"):
module._private_output_directory(str(ROOT / "outputs"))
def test_runner_points_to_the_gated_bilingual_delivery_compiler():
source = MODULE_PATH.read_text(encoding="utf-8")
# 原值: 源码点名 compose_full_synastry_delivery.py,并写 "Write independent Chinese and English section payloads"
# 新值: 源码点名 validate_bilingual_synastry_delivery.py,下一步是独立写中英报告
# 原因: 已验收的技能脚本不再调用 compose 编译器。技能六文件不改。
assert "validate_bilingual_synastry_delivery.py" in source
assert "Write Chinese and English reports independently" in source