diff --git a/scripts/run_monthly_codex_audit.py b/scripts/run_monthly_codex_audit.py index e4eb3dd..b7e16fe 100644 --- a/scripts/run_monthly_codex_audit.py +++ b/scripts/run_monthly_codex_audit.py @@ -19,11 +19,14 @@ import urllib.parse import urllib.request -from service.model_router import route_model +ROOT = Path(__file__).resolve().parents[1] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) + +from service.model_router import route_model # noqa: E402 API_BASE = "https://api.github.com" -ROOT = Path(__file__).resolve().parents[1] PROMPT_TEMPLATES = { "monthly_snapshot_audit": ROOT / "prompts" / "monthly_crypto_snapshot_audit.md", "long_horizon_signal_shadow": ROOT / "prompts" / "long_horizon_signal_shadow.md", diff --git a/tests/test_run_monthly_codex_audit.py b/tests/test_run_monthly_codex_audit.py index 471d77c..9ed564a 100644 --- a/tests/test_run_monthly_codex_audit.py +++ b/tests/test_run_monthly_codex_audit.py @@ -3,6 +3,7 @@ import json import os import subprocess +import sys import tempfile import threading import time @@ -93,6 +94,25 @@ def _normalized_policy(policy: dict[str, object]) -> dict[str, object]: class RunMonthlyCodexAuditTests(unittest.TestCase): + def test_script_entrypoint_can_import_service_from_repo_root(self) -> None: + repo_root = Path(__file__).resolve().parents[1] + env = dict(os.environ) + env.pop("PYTHONPATH", None) + env["ISSUE_NUMBER"] = "" + + result = subprocess.run( + [sys.executable, "scripts/run_monthly_codex_audit.py"], + cwd=repo_root, + env=env, + capture_output=True, + text=True, + check=False, + ) + + self.assertEqual(result.returncode, 1) + self.assertIn("ISSUE_NUMBER must be provided as an integer", result.stderr) + self.assertNotIn("ModuleNotFoundError", result.stderr) + def test_parse_bool_accepts_common_true_values(self) -> None: for value in ("1", "true", "TRUE", "yes", "on", True): self.assertTrue(parse_bool(value))