Files
fckbot/tests/integration/test_endpoints.py
Markov Andrey 508daebe53 Add new file
2026-06-30 20:55:14 +00:00

27 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.
"""
Интеграционные тесты для новых эндпоинтов RAG-сервера.
"""
import pytest
import httpx
from unittest.mock import AsyncMock, patch
# Используем httpx.AsyncClient для запросов к приложению
# Предполагаем, что приложение запущено в тестовом режиме или используем TestClient из FastAPI.
@pytest.mark.asyncio
async def test_clear_endpoint():
# В реальном тесте нужно запустить приложение и использовать TestClient.
# Здесь приведён пример с моками.
async with httpx.AsyncClient() as client:
# Мокаем зависимость
with patch("rag.rag_server.get_orchestrator") as mock_orch:
mock_orch.return_value.clear_kb = AsyncMock(return_value={"status": "ok"})
response = await client.post(
"http://localhost:8080/rag/clear",
json={"user_jid": "test@domain", "room_jid": None, "is_global": False},
headers={"X-API-Key": "testkey"}
)
assert response.status_code == 200
data = response.json()
assert data.get("status") == "ok"