2026-03-12 11:44:52 +08:00
|
|
|
from src.bot.runtime_coordinator import RuntimeStatus, StartupCoordinator, render_runtime_status_html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DummyBot:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_startup_coordinator_respects_disable_flags(monkeypatch):
|
|
|
|
|
monkeypatch.delenv("TELEGRAM_CHAT_ID", raising=False)
|
|
|
|
|
|
|
|
|
|
coordinator = StartupCoordinator(
|
|
|
|
|
bot=DummyBot(),
|
|
|
|
|
config={},
|
2026-03-20 20:59:30 +08:00
|
|
|
command_access_mode="group_member",
|
2026-03-12 11:44:52 +08:00
|
|
|
protected_commands=["/city", "/deb"],
|
2026-03-20 20:59:30 +08:00
|
|
|
required_group_chat_id="-1001234567890",
|
2026-03-12 11:44:52 +08:00
|
|
|
)
|
|
|
|
|
runtime = coordinator.start_all()
|
|
|
|
|
loop_map = runtime.loop_map()
|
|
|
|
|
|
2026-05-26 02:11:27 +08:00
|
|
|
assert "weekly_reward" in loop_map
|
|
|
|
|
assert "polygon_wallet_watch" not in loop_map
|
2026-03-12 11:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_render_runtime_status_html_contains_key_fields():
|
|
|
|
|
runtime = RuntimeStatus(
|
|
|
|
|
started_at="2026-03-12 00:00:00 UTC",
|
2026-03-20 20:59:30 +08:00
|
|
|
command_access_mode="group_member",
|
2026-03-12 11:44:52 +08:00
|
|
|
protected_commands=["/city", "/deb"],
|
2026-03-20 20:59:30 +08:00
|
|
|
required_group_chat_id="-1001234567890",
|
2026-03-12 11:44:52 +08:00
|
|
|
loops=[],
|
|
|
|
|
)
|
|
|
|
|
html = render_runtime_status_html(runtime)
|
|
|
|
|
|
|
|
|
|
assert "Bot 启动诊断" in html
|
2026-03-20 20:59:30 +08:00
|
|
|
assert "命令准入" in html
|
2026-03-12 11:44:52 +08:00
|
|
|
assert "/city, /deb" in html
|