/
pa1ch
/
FitAssistant
Обзор
Документация
Войти
/
pa1ch
/
FitAssistant
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/unit/test_ai_toggle.py
38 строк
1 KB
Pavel Chugaev
refactor(bot): свести бота к голосовому вводу и доставке (web-first)
19 июн 2026, 08:35
19 июн 2026, 08:35
a4ce963
Код
Авторство
О чём код?
"""Tests for the AI_ENABLED master switch gating AI-powered features.""" from unittest.mock import patch from app.bot.bot import create_dispatcher from app.bot.handlers import ai_workout, start from app.bot.handlers.start import _help_text def test_dispatcher_excludes_ai_router_when_disabled(): # aiogram routers are singletons that can only attach to one dispatcher, so # create_dispatcher() can be called only once per session. We assert the # disabled path here; the enabled path is exercised by the running app and # the voice API integration tests. with patch("app.bot.bot.settings.ai_enabled", False): dp = create_dispatcher() assert ai_workout.router not in dp.sub_routers # Non-AI routers are still wired up. assert start.router in dp.sub_routers def test_help_text_mentions_ai_when_enabled(): with patch("app.bot.handlers.start.settings.ai_enabled", True): text = _help_text() assert "/analyze" in text assert "/log" in text assert "голосовое" in text def test_help_text_omits_ai_when_disabled(): with patch("app.bot.handlers.start.settings.ai_enabled", False): text = _help_text() assert "/analyze" not in text assert "/log" not in text assert "голосовое" not in text # The web app pointer and generic commands remain documented. assert "приложении" in text assert "/cancel" in text