From 508daebe5317c31ab6ce3b0be07ed0fbd70d9c4a Mon Sep 17 00:00:00 2001 From: Markov Andrey Date: Tue, 30 Jun 2026 20:55:14 +0000 Subject: [PATCH] Add new file --- tests/integration/test_endpoints.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/integration/test_endpoints.py diff --git a/tests/integration/test_endpoints.py b/tests/integration/test_endpoints.py new file mode 100644 index 0000000..dab884e --- /dev/null +++ b/tests/integration/test_endpoints.py @@ -0,0 +1,27 @@ +""" +Интеграционные тесты для новых эндпоинтов 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" \ No newline at end of file