LichessStatTgWeb/tests/bot/test_wiring.py
vrubelroman a7571f13c1
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 16s
v1.5.1: not-found players paused, tests in repo + CI, log-based daily summary, docs pruned
- players absent from two consecutive bulk answers (deleted/renamed on Lichess) are paused
  like closed accounts with their own notice; ❓ mark; stats service answers 404 instead
  of "0 games" for unknown users
- /getgamers table stays unmarked, a legend line under it lists closed / not-found players
- daily SUMMARY is computed from events.log (survives restarts); lichess_429 comes from the
  stats service /health, which now exposes lichess_429_24h / lichess_429_total
- admin /status reads its numbers through Database.get_admin_stats
- tests/: 36 bot + 15 service unittest cases, run_tests.sh runs them inside the real images,
  CI runs them after the build and before pushing/deploying
- docs: USER_GUIDE/about/API_DOCUMENTATION rewritten for the current code, ARCHITECTURE.md and
  two sub-READMEs removed, 7 obsolete helper scripts removed, CURRENT_STATE updated
- .claude/agents/designer.md: Telegram-aware designer role

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-21 02:48:00 +00:00

33 lines
1.1 KiB
Python

"""Handler wiring of both bots against the real python-telegram-bot: the handler counts per group."""
from tests.bot import _env # noqa: F401 (environment before bot imports)
import unittest
from telegram.ext import Application
from bot import LichessBot
from admin_bot import AdminBot
DUMMY_TOKEN = "123456:ABCDEF"
def handler_groups(application: Application) -> dict:
return {group: len(handlers) for group, handlers in application.handlers.items()}
class WiringTests(unittest.TestCase):
def test_user_bot_handlers(self):
application = Application.builder().token(DUMMY_TOKEN).build()
bot = LichessBot()
bot.setup_handlers(application)
self.assertEqual({-1: 1, 0: 26}, handler_groups(application))
self.assertIs(application, bot.monitor.application)
def test_admin_bot_handlers(self):
application = Application.builder().token(DUMMY_TOKEN).build()
AdminBot().setup_handlers(application)
self.assertEqual({0: 6}, handler_groups(application))
if __name__ == '__main__':
unittest.main()