1
This commit is contained in:
parent
f3c96c3a72
commit
3e327a9649
@ -1,6 +1,7 @@
|
||||
from fastapi import APIRouter, Cookie, HTTPException, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
from app.config.system_config import seed_runtime_system_defaults
|
||||
from app.db import auth_db
|
||||
from app.db.scheduler_db import (
|
||||
enqueue_manual_trigger,
|
||||
@ -86,6 +87,8 @@ def build_router(templates):
|
||||
@router.get("/api/runtime-config")
|
||||
async def api_runtime_config(kind: str = "all", altcoin_session: str = Cookie(default="")):
|
||||
require_admin(altcoin_session)
|
||||
if kind in ("all", "system"):
|
||||
seed_runtime_system_defaults()
|
||||
if kind == "strategy":
|
||||
return {"items": list_configs("strategy")}
|
||||
if kind == "system":
|
||||
|
||||
@ -6,7 +6,7 @@ from app.config import config_loader
|
||||
from app.config.system_config import bootstrap_admin_config, email_config, notification_config, scheduler_config
|
||||
from app.db import auth_db
|
||||
from app.db.paper_trading import get_paper_trading_summary
|
||||
from app.db.runtime_config_db import get_event_sources, set_config, set_event_driven_config, set_event_sources, set_strategy_meta
|
||||
from app.db.runtime_config_db import delete_config, get_event_sources, set_config, set_event_driven_config, set_event_sources, set_strategy_meta
|
||||
from app.integrations import feishu_push
|
||||
from app.services.llm_insights import get_llm_module_enabled, get_llm_params
|
||||
from app.services.onchain_monitor import get_onchain_params
|
||||
@ -178,6 +178,19 @@ def test_runtime_config_api_can_manage_system_config():
|
||||
assert "event_driven.sources" in keys
|
||||
|
||||
|
||||
def test_runtime_config_api_seeds_all_system_defaults_when_listing():
|
||||
for key in ["llm", "onchain", "paper_trading", "notification", "email", "bootstrap_admin", "scheduler"]:
|
||||
delete_config("system", key)
|
||||
|
||||
client = TestClient(web_server.app)
|
||||
resp = client.get("/api/runtime-config?kind=system")
|
||||
|
||||
assert resp.status_code == 200
|
||||
keys = {x["config_key"] for x in resp.json()["items"]}
|
||||
for key in ["llm", "onchain", "paper_trading", "notification", "email", "bootstrap_admin", "scheduler"]:
|
||||
assert key in keys
|
||||
|
||||
|
||||
def test_llm_system_config_overrides_env_defaults(monkeypatch):
|
||||
monkeypatch.setenv("ALPHAX_LLM_ENABLED", "0")
|
||||
set_config("system", "llm", {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user