Files
fckbot/core/tests/test_check_spelling.py
Markov Andrey 76f039d544 Add new file
2026-06-30 09:21:27 +00:00

35 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""
Тесты для модуля проверки орфографии (только логика парсинга, без реального вызова LLM).
"""
import pytest
from unittest.mock import AsyncMock, MagicMock
from core.functions.check_spelling import check_spelling
@pytest.mark.asyncio
async def test_spelling_no_errors():
"""
Тест: если ошибок нет, возвращается пустой словарь.
"""
# Создаём мок бота с минимальными настройками
bot = MagicMock()
bot.ai_prompts = {'spellcheck': 'Ты — корректор...'}
bot.config = MagicMock()
bot.config.chunk_size_tokens = 200
bot.config.overlap_tokens = 50
bot.config.chunking_approx_chunk_chars = 500
bot.config.chunking_approx_overlap_chars = 100
# Мокаем giga.chat, чтобы он возвращал ответ без исправлений
bot.giga = AsyncMock()
bot.giga.chat.return_value = "[CORRECTED]\nТекст без ошибок\n[/CORRECTED]\n[CHANGES]\n[/CHANGES]"
replacements, changes = await check_spelling(
bot=bot,
original_text="Текст без ошибок",
original_path="/tmp/test.docx"
)
assert replacements == {}
assert changes == []