Редактировать test_critique.py
This commit is contained in:
60
tests/test_critique.py
Normal file
60
tests/test_critique.py
Normal file
@@ -0,0 +1,60 @@
|
||||
# -*- 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()
|
||||
Reference in New Issue
Block a user