Files
fckbot/tests/test_critique.py
2026-06-30 10:34:54 +00:00

60 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
"""
Тесты для модуля самокритики.
"""
import pytest
from core.functions.critique_answer import critique_answer
@pytest.mark.asyncio
async def test_critique_ok(mock_giga, mock_bot_config):
"""
Тест: если ответ хороший, возвращается True.
"""
mock_giga.chat.return_value = "[OK]"
result = await critique_answer(
giga=mock_giga,
query="Какой OEE?",
context="OEE 85%",
answer="OEE 85%",
prompt_text="Ты — контролёр качества...",
bot_config=mock_bot_config
)
assert result is True
@pytest.mark.asyncio
async def test_critique_fail(mock_giga, mock_bot_config):
"""
Тест: если есть замечания, возвращается False.
"""
mock_giga.chat.return_value = "[ISSUES]\n- Галлюцинация\n[/ISSUES]"
result = await critique_answer(
giga=mock_giga,
query="Какой OEE?",
context="OEE 85%",
answer="OEE 90%",
prompt_text="Ты — контролёр качества...",
bot_config=mock_bot_config
)
assert result is False
@pytest.mark.asyncio
async def test_critique_empty_prompt(mock_giga, mock_bot_config):
"""
Тест: если промпт пуст, пропускаем критику (возвращаем True).
"""
result = await critique_answer(
giga=mock_giga,
query="Вопрос",
context="Контекст",
answer="Ответ",
prompt_text="",
bot_config=mock_bot_config
)
assert result is True
mock_giga.chat.assert_not_called()