Add new file
This commit is contained in:
35
core/tests/test_check_spelling.py
Normal file
35
core/tests/test_check_spelling.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# -*- 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 == []
|
||||
Reference in New Issue
Block a user