Files
fckbot/core/tests/test_consistency.py
Markov Andrey 7e92e558cb Add new file
2026-06-30 09:21:49 +00:00

56 lines
1.8 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 -*-
"""
Тесты для модуля проверки противоречий.
"""
import pytest
from core.functions.check_consistency import check_consistency
@pytest.mark.asyncio
async def test_consistency_ok(mock_giga, mock_bot_config):
"""
Тест: если противоречий нет, возвращается "[OK]".
"""
mock_giga.chat.return_value = "[OK]"
result = await check_consistency(
giga=mock_giga,
chunks=["OEE составляет 85%", "OEE составляет 85%"],
query="Какой OEE?",
prompt_text="Ты — эксперт по верификации...",
bot_config=mock_bot_config
)
assert "[OK]" in result
@pytest.mark.asyncio
async def test_consistency_conflict(mock_giga, mock_bot_config):
"""
Тест: при обнаружении противоречий возвращается "[CONFLICT]".
"""
mock_giga.chat.return_value = "[CONFLICT]\n- Расхождение в цифрах\n[/CONFLICT]"
result = await check_consistency(
giga=mock_giga,
chunks=["OEE 85%", "OEE 90%"],
query="Какой OEE?",
prompt_text="Ты — эксперт по верификации...",
bot_config=mock_bot_config
)
assert "[CONFLICT]" in result
@pytest.mark.asyncio
async def test_consistency_too_few_chunks(mock_giga, mock_bot_config):
"""
Тест: если меньше 2 фрагментов, возвращается сообщение об ошибке.
"""
result = await check_consistency(
giga=mock_giga,
chunks=["Один фрагмент"],
query="Какой OEE?",
prompt_text="Ты — эксперт...",
bot_config=mock_bot_config
)
assert "Недостаточно фрагментов" in result