LichessStatTgWeb/tests/bot/test_wiring.py
vrubelroman df6b582376 iteration 1: report with game table, /getgamers state screen, silent-30-days prompt, /today as one message, stats port bound to localhost
- periodic report rebuilt in HTML: title with games count, mode lines, one <pre>
  table (± · colour · accuracy · opponent rating · opponent accuracy), 10-row cap,
  span note after catch-up; stats service returns tracked_rating_diff per game
- /getgamers shows player state from the DB (played today / N days quiet /
  closed / not found, report period) without Lichess calls; ratings on a button
- "player silent 30 days — keep?" prompt with keep/delete buttons, repeat 90 days
- /today, /yesterday, /week: one message edited into the result, nav buttons
- /year localised; active-gamer leftovers and N/A removed; one period wording
- docker-compose.prod.yml: stats port 8002 bound to 127.0.0.1
- product review docs: user journeys, concepts, Mini App feasibility, proposal

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

34 lines
1.2 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)
# 1 conversation + 17 commands + name text + 11 callbacks + non-text + unknown command
self.assertEqual({-1: 1, 0: 30}, 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: 7}, handler_groups(application)) # 2 conversations + start, status, counters, events, events_file
if __name__ == '__main__':
unittest.main()