Редактировать test_endpoints.py
This commit is contained in:
@@ -6,15 +6,9 @@ import pytest
|
|||||||
import httpx
|
import httpx
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
# Используем httpx.AsyncClient для запросов к приложению
|
|
||||||
# Предполагаем, что приложение запущено в тестовом режиме или используем TestClient из FastAPI.
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_clear_endpoint():
|
async def test_clear_endpoint():
|
||||||
# В реальном тесте нужно запустить приложение и использовать TestClient.
|
|
||||||
# Здесь приведён пример с моками.
|
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
# Мокаем зависимость
|
|
||||||
with patch("rag.rag_server.get_orchestrator") as mock_orch:
|
with patch("rag.rag_server.get_orchestrator") as mock_orch:
|
||||||
mock_orch.return_value.clear_kb = AsyncMock(return_value={"status": "ok"})
|
mock_orch.return_value.clear_kb = AsyncMock(return_value={"status": "ok"})
|
||||||
response = await client.post(
|
response = await client.post(
|
||||||
|
|||||||
Reference in New Issue
Block a user