"""The Telegram commands — the chat is a remote control, so it needs testing.""" from __future__ import annotations from app.services import settings_service, tasks_service, telegram_bot def test_unknown_input_is_ignored(session): assert telegram_bot.handle_text("hello there") is None assert telegram_bot.handle_text("/nonsense") is None def test_help_lists_the_verbs(session): reply = telegram_bot.handle_text("/help") assert "/start_work" in reply and "/report" in reply def test_start_pause_resume_and_status(session): assert "started" in telegram_bot.handle_text("/start_work 10").lower() status = telegram_bot.handle_text("/status") assert "work" in status.lower() or "focus" in status.lower() assert "Paused" in telegram_bot.handle_text("/pause") assert "Resumed" in telegram_bot.handle_text("/resume") assert "Stopped" in telegram_bot.handle_text("/stop") def test_stop_without_a_timer_explains_itself(session): assert "No interval is running" in telegram_bot.handle_text("/stop") def test_today_lists_and_numbers_the_tasks(session): settings_service.load_settings(session) tasks_service.create_local_task(session, title="Alpha task") tasks_service.create_local_task(session, title="Beta task") listing = telegram_bot.handle_text("/today") assert "Alpha task" in listing and "1." in listing def test_there_is_no_done_command(session): """Tasks are closed in their own tool; the bot must not pretend otherwise.""" assert telegram_bot.handle_text("/done 1") is None assert "/done" not in telegram_bot.handle_text("/help") def test_report_and_streak_render(session): assert "Daily report" in telegram_bot.handle_text("/report") assert "Streak" in telegram_bot.handle_text("/streak") assert "Weekly review" in telegram_bot.handle_text("/week") def test_block_command_describes_the_policy(session): settings = settings_service.load_settings(session) settings.blocker.enabled = True settings.blocker.blocked_domains = ["youtube.com"] settings_service.save_settings(session, settings) reply = telegram_bot.handle_text("/block") assert "Blocker" in reply and "Domains" in reply def test_russian_replies_when_configured(session): settings = settings_service.load_settings(session) settings.notifications.report.language = "ru" settings_service.save_settings(session, settings) assert "помидорку" in telegram_bot.handle_text("/help")