Files
crypto_monitor/tests/test_hub_strategy_lib.py
T
dekun 7223b54ec4 feat: add hub strategy docs page with MD and checklists
Central /strategy page shows per-exchange strategy markdown and read-only entry checklists; nav toggle in settings, print and HTML export per tab.

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

40 lines
1.2 KiB
Python

import json
import unittest
from pathlib import Path
from lib.hub.hub_strategy_lib import (
load_checklist,
load_strategy_payload,
strategy_meta_payload,
build_export_html,
)
class TestHubStrategyLib(unittest.TestCase):
def test_meta_has_three_exchanges(self):
meta = strategy_meta_payload()
keys = [x["key"] for x in meta["exchanges"]]
self.assertEqual(keys, ["binance", "okx", "gate"])
def test_load_binance_payload(self):
p = load_strategy_payload("binance")
self.assertTrue(p["ok"])
self.assertIn("strategy_html", p)
self.assertIn("groups", p["checklist"])
self.assertIn("<h2", p["strategy_html"].lower())
def test_checklist_files_valid_json(self):
root = Path(__file__).resolve().parent.parent / "docs" / "strategy" / "checklists"
for name in ("binance", "okx", "gate"):
data = json.loads((root / f"{name}.json").read_text(encoding="utf-8"))
self.assertTrue(data.get("groups"))
def test_export_html_contains_checklist(self):
html = build_export_html("gate")
self.assertIn("Gate", html)
self.assertIn("", html)
if __name__ == "__main__":
unittest.main()