69 lines
2.1 KiB
Python
69 lines
2.1 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from zoneinfo import ZoneInfo
|
|
|
|
from assistant_bot import application as application_module
|
|
from assistant_bot.auth import authentication_guard
|
|
from assistant_bot.config import AppSettings
|
|
from assistant_bot.handlers import (
|
|
ask_command,
|
|
help_command,
|
|
history_command,
|
|
inline_query,
|
|
model_command,
|
|
models_command,
|
|
new_conversation_command,
|
|
private_text,
|
|
private_voice,
|
|
start,
|
|
)
|
|
|
|
|
|
class ApplicationRegistrationTests(unittest.TestCase):
|
|
def test_registers_the_current_public_handlers_in_order(self) -> None:
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
settings = AppSettings(
|
|
bot_token="123456:TEST",
|
|
assistant_password="secret",
|
|
db_path=Path(directory) / "assistant.sqlite3",
|
|
mode="local",
|
|
timezone=ZoneInfo("UTC"),
|
|
voice_max_duration_seconds=120,
|
|
ollama_base_url="http://localhost:11434",
|
|
ollama_model="qwen3.5:9b",
|
|
yandex_cloud_folder=None,
|
|
yandex_cloud_model="yandexgpt/latest",
|
|
yandex_stt_model="general",
|
|
yandex_stt_language="ru-RU",
|
|
whisper_model="small",
|
|
whisper_device="cpu",
|
|
whisper_compute_type="int8",
|
|
whisper_language="ru",
|
|
)
|
|
application = application_module.create_application(settings)
|
|
|
|
self.assertEqual(
|
|
[handler.callback for handler in application.handlers[-1]],
|
|
[authentication_guard],
|
|
)
|
|
self.assertEqual(
|
|
[handler.callback for handler in application.handlers[0]],
|
|
[
|
|
start,
|
|
help_command,
|
|
ask_command,
|
|
models_command,
|
|
model_command,
|
|
new_conversation_command,
|
|
history_command,
|
|
inline_query,
|
|
private_voice,
|
|
private_text,
|
|
],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|