feat: expose safe vedastro health status

This commit is contained in:
732642856
2026-07-19 12:27:25 +08:00
parent 6e45b1ba1a
commit 1c6f7adf91
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -1450,6 +1450,7 @@ class JyotishAPIHandler(BaseHTTPRequestHandler):
endpoint = os.environ.get('VEDASTRO_API_ENDPOINT', '').strip()
network_flag = os.environ.get('VEDASTRO_ENABLE_NETWORK', '').strip().lower()
network_enabled = network_flag in {'1', 'true', 'yes'}
has_api_key = bool(os.environ.get('VEDASTRO_API_KEY', '').strip())
parsed = urlparse(endpoint) if endpoint else None
configured = bool(endpoint)
if not configured:
@@ -1474,6 +1475,7 @@ class JyotishAPIHandler(BaseHTTPRequestHandler):
'status': status,
'configured': configured,
'network_enabled': network_enabled,
'has_api_key': has_api_key,
'endpoint_host': parsed.netloc if parsed else None,
'required_env': {
'endpoint': 'VEDASTRO_API_ENDPOINT',
@@ -1538,6 +1540,7 @@ class JyotishAPIHandler(BaseHTTPRequestHandler):
'ayanamsa_default': 'lahiri',
'modules': 'Chart/KP/Synastry/Prashna/Remedies/Dasha/Varga/Jaimini/Ashtakavarga/Shadbala/Yoga/Aspects/Tajika/Muhurta/BhavaChalit/BhavaBala/Sudarshana/Nakshatra/Transit/RectificationGate/CaseValidation/DivisionalYoga/Kakshya',
'async_job_runtime': async_job_runtime_status(),
'vedastro': self._vedastro_status(),
})
elif path == '/api/cities':
self._json(list(CITY_DB.keys()))
+4
View File
@@ -215,6 +215,10 @@ def test_health_endpoint_exposes_runtime_accuracy_metadata() -> None:
assert payload['ayanamsa_default'] == 'lahiri'
assert 'swisseph_available' in payload
assert 'swisseph_version' in payload
assert payload['vedastro']['configured'] is False
assert payload['vedastro']['network_enabled'] is False
assert payload['vedastro']['has_api_key'] is False
assert 'VEDASTRO_API_KEY=' not in json.dumps(payload['vedastro'])
def test_vedastro_status_endpoint_exposes_safe_adapter_state(monkeypatch) -> None: