Files
Nexus/tests/test_prod_probe.py
T
Nexus Agent b62f1039db feat(ops): add production probe with dual-path health checks.
SSH origin checks cover auth contracts and once-schedule create/delete
when external HTTPS is blocked; includes install script for probe credentials.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 03:28:17 +08:00

38 lines
968 B
Python

"""Unit tests for scripts/prod_probe.py helpers."""
from __future__ import annotations
import json
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
from prod_probe import assert_json, build_config # noqa: E402
def test_assert_json_ok():
data = assert_json(200, json.dumps({"a": 1}), "/x")
assert data["a"] == 1
def test_assert_json_fail_status():
with pytest.raises(RuntimeError, match="HTTP 500"):
assert_json(500, "err", "/x")
def test_build_config_defaults(monkeypatch):
monkeypatch.delenv("NEXUS_PROBE_BASE", raising=False)
monkeypatch.delenv("NEXUS_SSH", raising=False)
monkeypatch.setattr(
"prod_probe._load_secrets_env",
lambda: None,
)
cfg = build_config()
assert cfg.base_external == "https://api.synaglobal.vip"
assert cfg.ssh_host == "nexus"
assert cfg.origin_url == "http://127.0.0.1:8600"