Files
crypto_monitor_user/tests/test_sanitize_hub_settings.py
T
dekun 53863559f4 Initialize crypto_monitor_user (user edition) from monitor codebase.
Retarget git remote, install path, and deploy docs from crypto_monitor to crypto_monitor_user.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 16:18:13 +08:00

42 lines
1.2 KiB
Python

"""deploy/sanitize_hub_settings.py 单元测试."""
from __future__ import annotations
import json
import sys
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO / "deploy"))
from sanitize_hub_settings import sanitize_settings # noqa: E402
def test_drops_gate_bot_and_keeps_gate():
raw = {
"exchanges": [
{"id": "0", "key": "binance", "name": "币安", "agent_url": "http://127.0.0.1:15200"},
{"id": "3", "key": "gate_bot", "name": "Gate bot", "agent_url": "http://127.0.0.1:15203"},
{"id": "2", "key": "gate", "name": "Gate", "flask_url": "http://127.0.0.1:5000"},
]
}
cleaned, removed = sanitize_settings(raw)
keys = [x["key"] for x in cleaned["exchanges"]]
assert keys == ["binance", "gate"]
assert len(removed) == 1
def test_drops_port_5002_legacy():
raw = {
"exchanges": [
{
"id": "3",
"key": "legacy",
"name": "crypto_monitor_gate_bot",
"flask_url": "http://127.0.0.1:5002",
},
]
}
cleaned, removed = sanitize_settings(raw)
assert cleaned["exchanges"] == []
assert removed