Add compact oracle and local env closure packs
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from scripts import local_env
|
||||
|
||||
|
||||
def test_load_local_env_reads_repo_env_file_without_overriding_explicit_env(tmp_path: Path, monkeypatch) -> None:
|
||||
env_file = tmp_path / ".env.local"
|
||||
env_file.write_text(
|
||||
"VEDASTRO_API_ENDPOINT=https://api.vedastro.org/api\n"
|
||||
"VEDASTRO_ENABLE_NETWORK=1\n"
|
||||
"VEDASTRO_API_KEY=from_file\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.delenv("VEDASTRO_API_ENDPOINT", raising=False)
|
||||
monkeypatch.setenv("VEDASTRO_API_KEY", "from_process")
|
||||
|
||||
try:
|
||||
loaded = local_env.load_local_env(root=tmp_path)
|
||||
|
||||
assert loaded == [env_file]
|
||||
assert os.environ["VEDASTRO_API_ENDPOINT"] == "https://api.vedastro.org/api"
|
||||
assert os.environ["VEDASTRO_ENABLE_NETWORK"] == "1"
|
||||
assert os.environ["VEDASTRO_API_KEY"] == "from_process"
|
||||
finally:
|
||||
os.environ.pop("VEDASTRO_API_ENDPOINT", None)
|
||||
os.environ.pop("VEDASTRO_ENABLE_NETWORK", None)
|
||||
|
||||
|
||||
def test_load_local_env_ignores_missing_file(tmp_path: Path, monkeypatch) -> None:
|
||||
monkeypatch.delenv("VEDASTRO_API_ENDPOINT", raising=False)
|
||||
os.environ.pop("VEDASTRO_ENABLE_NETWORK", None)
|
||||
|
||||
loaded = local_env.load_local_env(root=tmp_path)
|
||||
|
||||
assert loaded == []
|
||||
assert "VEDASTRO_API_ENDPOINT" not in os.environ
|
||||
|
||||
|
||||
def test_load_local_env_does_not_resurrect_deleted_values_after_bootstrap(tmp_path: Path, monkeypatch) -> None:
|
||||
env_file = tmp_path / ".env.local"
|
||||
env_file.write_text("VEDASTRO_ENABLE_NETWORK=1\n", encoding="utf-8")
|
||||
monkeypatch.delenv("VEDASTRO_ENABLE_NETWORK", raising=False)
|
||||
|
||||
loaded = local_env.load_local_env(root=tmp_path)
|
||||
assert loaded == [env_file]
|
||||
assert os.environ["VEDASTRO_ENABLE_NETWORK"] == "1"
|
||||
|
||||
monkeypatch.delenv("VEDASTRO_ENABLE_NETWORK", raising=False)
|
||||
loaded_again = local_env.load_local_env(root=tmp_path)
|
||||
|
||||
assert loaded_again == []
|
||||
assert "VEDASTRO_ENABLE_NETWORK" not in os.environ
|
||||
|
||||
|
||||
def test_load_local_env_respects_explicit_skip_flag(tmp_path: Path, monkeypatch) -> None:
|
||||
env_file = tmp_path / ".env.local"
|
||||
env_file.write_text("VEDASTRO_API_ENDPOINT=https://api.vedastro.org/api\n", encoding="utf-8")
|
||||
monkeypatch.delenv("VEDASTRO_API_ENDPOINT", raising=False)
|
||||
monkeypatch.setenv("JYOTISH_SKIP_LOCAL_ENV", "1")
|
||||
|
||||
loaded = local_env.load_local_env(root=tmp_path)
|
||||
|
||||
assert loaded == []
|
||||
assert "VEDASTRO_API_ENDPOINT" not in os.environ
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regression tests for the batched oracle closure pack."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from scripts.oracle_batch_closure_pack import build_report
|
||||
|
||||
|
||||
def test_oracle_batch_closure_pack_combines_dasha_and_shadbala_truth() -> None:
|
||||
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
|
||||
|
||||
assert report["scope"] == "oracle_batch_closure_pack"
|
||||
assert report["summary"]["dasha_can_claim_closure"] is True
|
||||
assert report["summary"]["shadbala_case_count"] >= 2
|
||||
assert report["summary"]["shadbala_within_tolerance_case_count"] <= report["summary"]["shadbala_case_count"]
|
||||
assert any(item["kind"] == "dasha" for item in report["rows"])
|
||||
assert any(item["kind"] == "shadbala" for item in report["rows"])
|
||||
assert report["summary"]["global_oracle_closure_blocked"] is True
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regression tests for the minimal VedAstro ingestion closure pack."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from scripts.vedastro_ingestion_closure_pack import build_report
|
||||
|
||||
|
||||
def test_vedastro_ingestion_closure_pack_reuses_blocked_and_allowlisted_paths() -> None:
|
||||
report = build_report()
|
||||
|
||||
assert report["scope"] == "vedastro_ingestion_closure_pack"
|
||||
assert report["summary"]["range_scan_domains"] == ["career", "marriage", "wealth"]
|
||||
assert report["summary"]["schema_declares_allowlist"] is True
|
||||
assert report["summary"]["unconfigured_status"] == "service_endpoint_not_configured"
|
||||
assert report["summary"]["network_preview_status"] == "network_execution_disabled"
|
||||
assert report["summary"]["life_event_graph_accepts_external_window"] is True
|
||||
assert report["summary"]["global_live_closure_blocked"] is True
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regression tests for user-visible Vimsopaka semantic summaries."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from scripts.jyotish_engine import _build_vimsopaka_semantic_summary
|
||||
|
||||
|
||||
def test_build_vimsopaka_semantic_summary_surfaces_high_value_dignity_terms() -> None:
|
||||
summary = _build_vimsopaka_semantic_summary({
|
||||
"Sun": {"dignity": "GREAT_FRIEND"},
|
||||
"Moon": {"dignity": "NEECHA_BHANGA"},
|
||||
"Mars": {"dignity": "GREAT_ENEMY"},
|
||||
})
|
||||
|
||||
assert "Great Friend" in summary["highlights"][0] or "极友" in summary["highlights"][0]
|
||||
assert any("Neecha Bhanga" in item or "落陷取消" in item for item in summary["highlights"])
|
||||
assert any("Great Enemy" in item or "极敌" in item for item in summary["warnings"])
|
||||
assert summary["status"] == "used"
|
||||
Reference in New Issue
Block a user